exec

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MIT Imports: 14 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureDir

func EnsureDir(dir string) (err error)

EnsureDir checks and creates the directory.

func EnsureDirEnh

func EnsureDirEnh(dir string) (err error)

EnsureDirEnh checks and creates the directory, via sudo if necessary.

func FileExists

func FileExists(filepath string) bool

FileExists returns the existence of an directory or file

func FileModeIs added in v0.2.3

func FileModeIs(filepath string, tester func(mode os.FileMode) bool) (ret bool)

FileModeIs tests the mode of 'filepath' with 'tester'. Examples:

var yes = exec.FileModeIs("/etc/passwd", exec.IsModeExecAny)
var yes = exec.FileModeIs("/etc/passwd", exec.IsModeDirectory)

func ForDir added in v0.1.18

func ForDir(root string, cb func(depth int, cwd string, fi os.FileInfo) (stop bool, err error)) (err error)

ForDir walks on `root` directory and its children

func ForDirMax added in v0.1.18

func ForDirMax(root string, initialDepth, maxDepth int, cb func(depth int, cwd string, fi os.FileInfo) (stop bool, err error)) (err error)

ForDirMax walks on `root` directory and its children with nested levels up to `maxLength`.

Example - discover folder just one level

     _ = ForDirMax(dir, 0, 1, func(depth int, cwd string, fi os.FileInfo) (stop bool, err error) {
			if fi.IsDir() {
				return
			}
         // ... doing something for a file,
			return
		})

maxDepth = -1: no limit. initialDepth: 0 if no idea.

func GetCurrentDir

func GetCurrentDir() string

GetCurrentDir returns the current workingFlag directory it should be equal with os.Getenv("PWD")

func GetExecutableDir

func GetExecutableDir() string

GetExecutableDir returns the executable file directory

func GetExecutablePath added in v0.1.16

func GetExecutablePath() string

GetExecutablePath returns the executable file path

func IsDirectory

func IsDirectory(filepath string) (bool, error)

IsDirectory tests whether `path` is a directory or not

func IsEAccess

func IsEAccess(err error) bool

IsEAccess detects whether err is a EACCESS errno or not

func IsExitError

func IsExitError(err error) (int, bool)

IsExitError checks the error object

func IsModeCharDevice added in v0.2.3

func IsModeCharDevice(mode os.FileMode) bool

IsModeCharDevice give the result of whether a file is a character device

func IsModeDevice added in v0.2.3

func IsModeDevice(mode os.FileMode) bool

IsModeDevice give the result of whether a file is a device

func IsModeDirectory added in v0.2.3

func IsModeDirectory(mode os.FileMode) bool

IsModeDirectory give the result of whether a file is a directory

func IsModeExecAll added in v0.2.3

func IsModeExecAll(mode os.FileMode) bool

IsModeExecAll give the result of whether a file can be invoked by all users

func IsModeExecAny added in v0.2.3

func IsModeExecAny(mode os.FileMode) bool

IsModeExecAny give the result of whether a file can be invoked by anyone

func IsModeExecGroup added in v0.2.3

func IsModeExecGroup(mode os.FileMode) bool

IsModeExecGroup give the result of whether a file can be invoked by its unix-group

func IsModeExecOther added in v0.2.3

func IsModeExecOther(mode os.FileMode) bool

IsModeExecOther give the result of whether a file can be invoked by its unix-all

func IsModeExecOwner added in v0.2.3

func IsModeExecOwner(mode os.FileMode) bool

IsModeExecOwner give the result of whether a file can be invoked by its unix-owner

func IsModeIrregular added in v0.2.3

func IsModeIrregular(mode os.FileMode) bool

IsModeIrregular give the result of whether a file is a non-regular file; nothing else is known about this file

func IsModeNamedPipe added in v0.2.3

func IsModeNamedPipe(mode os.FileMode) bool

IsModeNamedPipe give the result of whether a file is a named pipe

func IsModeReadAll added in v0.2.3

func IsModeReadAll(mode os.FileMode) bool

IsModeReadAll give the result of whether a file can be read by all users

func IsModeReadAny added in v0.2.3

func IsModeReadAny(mode os.FileMode) bool

IsModeReadAny give the result of whether a file can be read by anyone

func IsModeReadGroup added in v0.2.3

func IsModeReadGroup(mode os.FileMode) bool

IsModeReadGroup give the result of whether a file can be read by its unix-group

func IsModeReadOther added in v0.2.3

func IsModeReadOther(mode os.FileMode) bool

IsModeReadOther give the result of whether a file can be read by its unix-all

func IsModeReadOwner added in v0.2.3

func IsModeReadOwner(mode os.FileMode) bool

IsModeReadOwner give the result of whether a file can be read by its unix-owner

func IsModeRegular added in v0.2.3

func IsModeRegular(mode os.FileMode) bool

IsModeRegular give the result of whether a file is a regular file

func IsModeSetgid added in v0.2.3

func IsModeSetgid(mode os.FileMode) bool

IsModeSetgid give the result of whether a file has the setgid bit

func IsModeSetuid added in v0.2.3

func IsModeSetuid(mode os.FileMode) bool

IsModeSetuid give the result of whether a file has the setuid bit

func IsModeSocket added in v0.2.3

func IsModeSocket(mode os.FileMode) bool

IsModeSocket give the result of whether a file is a socket file

func IsModeSticky added in v0.2.3

func IsModeSticky(mode os.FileMode) bool

IsModeSticky give the result of whether a file is a sticky file

func IsModeSymbolicLink(mode os.FileMode) bool

IsModeSymbolicLink give the result of whether a file is a symbolic link

func IsModeWriteAll added in v0.2.3

func IsModeWriteAll(mode os.FileMode) bool

IsModeWriteAll give the result of whether a file can be written by all users

func IsModeWriteAny added in v0.2.3

func IsModeWriteAny(mode os.FileMode) bool

IsModeWriteAny give the result of whether a file can be written by anyone

func IsModeWriteGroup added in v0.2.3

func IsModeWriteGroup(mode os.FileMode) bool

IsModeWriteGroup give the result of whether a file can be written by its unix-group

func IsModeWriteOther added in v0.2.3

func IsModeWriteOther(mode os.FileMode) bool

IsModeWriteOther give the result of whether a file can be written by its unix-all

func IsModeWriteOwner added in v0.2.3

func IsModeWriteOwner(mode os.FileMode) bool

IsModeWriteOwner give the result of whether a file can be written by its unix-owner

func IsRegularFile

func IsRegularFile(filepath string) (bool, error)

IsRegularFile tests whether `path` is a normal regular file or not

func NormalizeDir

func NormalizeDir(s string) string

NormalizeDir make dir name normalized

func RemoveDirRecursive

func RemoveDirRecursive(dir string) (err error)

RemoveDirRecursive removes a directory and any children it contains.

func Run

func Run(command string, arguments ...string) error

Run runs an OS command

func RunCommand

func RunCommand(command string, readStdout bool, arguments ...string) (retCode int, stdoutText string, err error)

RunCommand runs an OS command

func RunWithOutput

func RunWithOutput(command string, arguments ...string) (int, string, error)

RunWithOutput runs an OS command and collect the result outputting

func Sudo

func Sudo(command string, arguments ...string) (int, string, error)

Sudo runs an OS command with sudo prefix

Types

This section is empty.

Jump to

Keyboard shortcuts

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