Standard library / archive/zip
archive/zip.Writer.Close()
Finalize ZIP central directory. Does not close underlying writer; check this error before consuming archive. Expected stdout: '0\n'.
Formal Syntax & Structure
go syntaxgo
func (w *Writer) Close() errorReturn 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) must(w.Close()) r, e := zip.NewReader(bytes.NewReader(b.Bytes()), int64(b.Len())) must(e) fmt.Println(len(r.File))}