package main import ( "os" ) func main() { err := os.Chmod("path/to/file", 0644) if err != nil { panic(err) } }
package main import ( "os" ) func main() { err := os.Chmod("path/to/directory", 0755) if err != nil { panic(err) } }This code changes the permissions of the directory at "path/to/directory" to 0755, which gives the owner read, write, and execute access, and anyone else read and execute access. The File Chmod function is part of the Go standard library's "os" package.