Golang module to manipulate file mode bits on Linux systems.
go get github.com/g0rbe/go-filemodeSet(),Unset()and other functions are works withModetype.SetFile(),UnsetFile()and other...File()functions are works with*os.Filetype.SetPath(),UnsetPath()and other...Path()functions are works withstringthat specify the file's path. NOTE: These functions does not follows symlinks!
package main
import (
"fmt"
"github.com/g0rbe/go-filemode"
)
func main() {
if err := filemode.SetPath("/path/to/file", filemode.ExecOther); err != nil {
// Handle error
}
isSet, err := filemode.IsSetPath("/path/to/file", filemode.ExecOther)
if err != nil {
// Handle error
}
if !isSet {
fmt.Printf("%s in not executable\n", "/path/to/file")
}
}