Documentation
¶
Overview ¶
Package sys provides system level utilities.
Index ¶
- func CheckPid(pid int) error
- func GetFileMd5(path string) (string, error)
- func La(name string) ([]string, error)
- func ReadDir(dirname string) ([]os.FileInfo, error)
- func RunCmd(ctx context.Context, name, arg, wd, logFile string, ...) (err error)
- func Walk(root string, walkFn filepath.WalkFunc) error
- type CmdHook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPid ¶ added in v0.3.0
CheckPid checks if the process of pid exists. Ref: https://stackoverflow.com/questions/15204162/check-if-a-process-exists-in-go-way
func GetFileMd5 ¶ added in v0.3.0
GetFileMd5 computes the file MD5 as IO stream; note that this might takes time for large file.
func La ¶
La lists all files of the directory including hidden files and self/parent directory; it's behaviour is the same as calling `ls -a`.
func ReadDir ¶
ReadDir mimic the behaviour of ioutil.ReadDir (reads the directory named by dirname and returns a list of directory entries sorted by filename), but use `ls -a` and string parsing internally.
func RunCmd ¶ added in v0.3.0
func RunCmd(ctx context.Context, name, arg, wd, logFile string, afterStartFunc, doneFunc CmdHook) (err error)
RunCmd runs a command with specific arg in a blocking way; it calls doneFunc when the context is done.
func Walk ¶
Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Walk does not follow symbolic links.