sys

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: MIT Imports: 9 Imported by: 0

README

Sys

Readdir

List and walk directory using system utils ls. This offer an alternative to stdlib's filepath.Walk(). Their behaviours are the same most of the time (read from ls is much slower though), but it's the rare cases that they are different make this alternative useful (on network devices differences are observed, so as during travis-CI build broken)

TODO
  • Investige why the difference (filepath.Walk() read system blocks directly);
  • Determined test cases to see who is right;
  • Benchmark the slow down.

Documentation

Overview

Package sys provides system level utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPid added in v0.3.0

func CheckPid(pid int) error

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

func GetFileMd5(path string) (string, error)

GetFileMd5 computes the file MD5 as IO stream; note that this might takes time for large file.

func La

func La(name string) ([]string, error)

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

func ReadDir(dirname string) ([]os.FileInfo, error)

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

func Walk(root string, walkFn filepath.WalkFunc) error

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.

Types

type CmdHook added in v0.3.0

type CmdHook func(*exec.Cmd, io.WriteCloser)

CmdHook gives access to the executed Cmd and its stdin.

func SignalExit added in v0.3.0

func SignalExit(sig syscall.Signal) CmdHook

SignalExit sends SIGNAL to exit the process.

Jump to

Keyboard shortcuts

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