Standard library / archive/zip

archive/zip.Writer.SetComment()

Set central-directory archive comment, limited to 65535 bytes. Expected stdout: 'demo\n'.

Formal Syntax & Structure

go syntaxgo
func (w *Writer) SetComment(comment string) error

Parameters & Attributes

NameTypeDescription
commentstringArchive comment, at most 65535 bytes.

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)  must(w.SetComment("demo"))  must(w.Close())  r, e := zip.NewReader(bytes.NewReader(b.Bytes()), int64(b.Len()))  must(e)  fmt.Println(r.Comment)}
Go Reference