Standard library / archive/zip
archive/zip.FileHeader
ZIP metadata: Name/Comment/NonUTF8 describe text; CreatorVersion, ReaderVersion, Flags, Method and Extra describe format; Modified and legacy date/time fields describe timestamps; CRC32 and compressed/uncompressed sizes describe payload; prefer 64-bit sizes. ExternalAttrs stores mode-related metadata. Treat paths and declared sizes as untrusted. Expected stdout: 'a.txt -rw-------\n'.
Formal Syntax & Structure
go syntaxgo
type FileHeader struct { Name string
Comment string
NonUTF8 bool
CreatorVersion uint16 ReaderVersion uint16 Flags uint16
Method uint16
Modified time.Time
ModifiedTime uint16
ModifiedDate uint16
CRC32 uint32
CompressedSize uint32
UncompressedSize uint32
CompressedSize64 uint64
UncompressedSize64 uint64
Extra []byte ExternalAttrs uint32}Working Example
Example Snippetgo
package main
import ( "archive/zip" "fmt")
func must(e error) { if e != nil { panic(e) }}
func main() { h := zip.FileHeader{Name: "a.txt", Method: zip.Store} h.SetMode(0600) fmt.Println(h.Name, h.Mode().Perm())}