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) errorParameters & Attributes
| Name | Type | Description |
|---|---|---|
| comment | string | Archive 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)}