Standard library / archive/zip

archive/zip.Writer.Flush()

Flush buffered ZIP output to destination. It does not finalize the archive or necessarily flush an active compression stream. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (w *Writer) Flush() error

Return Value

error

Nil on success, otherwise operation error.

Working Example

Example Snippetgo
package main
import (  "archive/zip"  "bytes"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  var b bytes.Buffer  w := zip.NewWriter(&b)  _, e := w.CreateHeader(&zip.FileHeader{Name: "a.txt", Method: zip.Store})  must(e)  must(w.Flush())  fmt.Println(b.Len() > 0)  must(w.Close())}
Go Reference