https://github.com/g0rbe/go-filemode
Golang module to manipulate file mode bits on Linux systems.
https://github.com/g0rbe/go-filemode
chmod filemode filesystem golang linux
Last synced: about 1 year ago
JSON representation
Golang module to manipulate file mode bits on Linux systems.
- Host: GitHub
- URL: https://github.com/g0rbe/go-filemode
- Owner: g0rbe
- License: mit
- Created: 2023-12-18T05:07:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-18T06:27:18.000Z (over 2 years ago)
- Last Synced: 2025-04-01T00:34:21.311Z (about 1 year ago)
- Topics: chmod, filemode, filesystem, golang, linux
- Language: Go
- Homepage: https://gorbe.io/go/filemode
- Size: 9.77 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-filemode
[](https://pkg.go.dev/github.com/g0rbe/go-filemode)
[](https://goreportcard.com/report/github.com/g0rbe/go-filemode)
Golang module to manipulate file mode bits on Linux systems.
## Install
```bash
go get github.com/g0rbe/go-filemode
```
## Usage
- `Set()`, `Unset()` and other functions are works with `Mode` type.
- `SetFile()`, `UnsetFile()` and other `...File()` functions are works with `*os.File` type.
- `SetPath()`, `UnsetPath()` and other `...Path()` functions are works with `string` that specify the file's path. **NOTE**: These functions does not follows symlinks!
## Example
```go
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")
}
}
```