Skip to content

Latest commit

 

History

History
46 lines (32 loc) · 1.11 KB

README.md

File metadata and controls

46 lines (32 loc) · 1.11 KB

go-filemode

Go Reference Go Report Card

Golang module to manipulate file mode bits on Linux systems.

Install

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

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")
	}
}