Standard library / os
os.FileMode
Alias for io/fs.FileMode, representing permissions and type bits; not an ACL representation. Example uses a disposable temporary workspace. Expected stdout: '640 true\n'.
Formal Syntax & Structure
go syntaxgo
type FileMode = fs.FileModeWorking Example
Example Snippetgo
package main
import ( "fmt" "os")
func check(e error) { if e != nil { panic(e) }}func workspace() func() { root, e := os.MkdirTemp("", "bytemind-go-") check(e) old, e := os.Getwd() check(e) check(os.Chdir(root)) return func() { check(os.Chdir(old)); check(os.RemoveAll(root)) }}func main() { defer workspace()() var m os.FileMode = 0640 fmt.Printf("%o %v\n", m.Perm(), m.IsRegular())}