Standard library / archive/zip

archive/zip.FileHeader.SetMode()

Encode permission and type information into header attributes. Does not change a real file. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (h *FileHeader) SetMode(mode fs.FileMode)

Parameters & Attributes

NameTypeDescription
modefs.FileModeFile mode including permission and type bits.

Working Example

Example Snippetgo
package main
import (  "archive/zip"  "fmt"  "io/fs")
func must(e error) {  if e != nil {    panic(e)  }}
func main() { h := zip.FileHeader{}; h.SetMode(0700 | fs.ModeDir); fmt.Println(h.Mode().IsDir()) }
Go Reference