Skip to content

Golang module to manipulate file mode bits on Linux systems.

License

Notifications You must be signed in to change notification settings

g0rbe/go-filemode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Golang module to manipulate file mode bits on Linux systems.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages