common

package
v0.0.73 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PrivateFileMode grants owner to read/write a file.
	PrivateFileMode = 0600
	// PrivateDirMode grants owner to make/remove files inside the directory.
	PrivateDirMode = 0700
)

Variables

This section is empty.

Functions

func CheckDirPermission

func CheckDirPermission(dir string, perm os.FileMode) error

CheckDirPermission checks permission on an existing dir. Returns error if dir is empty or exist with a different permission than specified.

func Exist

func Exist(name string) bool

Exist returns true if a file or directory exists.

func GetEnvironment added in v0.0.48

func GetEnvironment(key string, alternativeKeys ...string) string

GetEnvironment retrieves the value of the environment variable named by the key. If the environment doesn't exist, we will lookup for alternative environment variables until we find an environment. Return empty environment value while no environment variables found.

func GetOrDefault

func GetOrDefault(key, def string, data map[string]string) (result string)

GetOrDefault returns the value or a default value from a map

func GetReplacement

func GetReplacement(key string, data map[string]string) (result string)

GetReplacement returns a string which replace via a map

func IsDirWriteable

func IsDirWriteable(dir string) error

IsDirWriteable checks if dir is writable by writing and removing a file to dir. It returns nil if dir is writable.

func ParseVersionNum added in v0.0.40

func ParseVersionNum(release string) string

ParseVersionNum split version from release or tag

func PathExists

func PathExists(path string) (bool, error)

PathExists checks if the target path exist or not

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL