Golang module to manipulate file mode bits on Linux systems.
go get github.com/g0rbe/go-filemode
Set()
,Unset()
and other functions are works withMode
type.SetFile()
,UnsetFile()
and other...File()
functions are works with*os.File
type.SetPath()
,UnsetPath()
and other...Path()
functions are works withstring
that 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")
}
}