Documentation
¶
Index ¶
- type Config
- type Echo
- func (e *Echo) Abs(path string) string
- func (e *Echo) AreSame(path0, path1 string) bool
- func (e *Echo) Base(path string) string
- func (e *Echo) Dir(path string) string
- func (e *Echo) Empty(val string) bool
- func (e *Echo) Env(val string) *Echo
- func (e *Echo) Eval(str string) string
- func (e *Echo) Ext(path string) string
- func (e *Echo) Glob(pathPattern string) []string
- func (e *Echo) IsAbs(path string) bool
- func (e *Echo) IsDir(path string) bool
- func (e *Echo) IsExist(path string) bool
- func (e *Echo) IsReg(path string) bool
- func (e *Echo) Lower(val string) string
- func (e *Echo) Mkdirs(paths string, modes ...uint32)
- func (e *Echo) PathJoin(paths ...string) string
- func (e *Echo) PathMatched(pattern, path string) bool
- func (e *Echo) PathSplit(path string) []string
- func (e *Echo) PathSym(path string) string
- func (e *Echo) Rel(base string, target string) string
- func (e *Echo) Rmdirs(paths string)
- func (e *Echo) Run(cmdStr string) string
- func (e *Echo) RunProc(cmdStr string) *ProcResult
- func (e *Echo) Runout(cmdStr string)
- func (e *Echo) SetEnv(name, value string) *Echo
- func (e *Echo) SetVar(name, value string) *Echo
- func (e *Echo) Split(list string, sep ...string) []string
- func (e *Echo) StartProc(cmdStr string) *ProcResult
- func (e *Echo) Streq(val0, val1 string) bool
- func (e *Echo) String() string
- func (e *Echo) Trim(val string) string
- func (e *Echo) Upper(val string) string
- func (e *Echo) Val(name string) string
- func (e *Echo) Var(val string) *Echo
- type ProcResult
- func (p *ProcResult) Err() error
- func (p *ProcResult) ExitCode() int
- func (p *ProcResult) Exited() bool
- func (p *ProcResult) ID() int
- func (p *ProcResult) IsSuccess() bool
- func (p *ProcResult) Out() io.Reader
- func (p *ProcResult) SysTime() time.Duration
- func (p *ProcResult) UserTime() time.Duration
- func (p *ProcResult) Wait()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config stores configuration
func (*Config) IsPanicOnErr ¶
IsPanicOnErr returns panic-on-error flag
func (*Config) SetPanicOnErr ¶
SetPanicOnErr panics program on any error
type Echo ¶
type Echo struct {
Conf *Config // session config
Proc *ProcResult // last executed proc
// contains filtered or unexported fields
}
Echo represents a new Echo session
func (*Echo) Abs ¶
Abs returns the absolute representation for path. Returns empty string if it fails for any reason.
func (*Echo) Env ¶
Env declares process environment variables using a multi-line space-separated list of KEY=VAL format: i.e. GOOS=linux GOARCH=amd64
func (*Echo) Eval ¶
Eval returns the string str with its content expanded with variable values i.e. Eval("I am $HOME") returns "I am <user home path>"
func (*Echo) Glob ¶
Glob uses shell file path pattern (i.e. /usr/*/*a) to return a []string of file names
func (*Echo) IsDir ¶
IsDir returns true if path is a directory. All other cases (errors) will return false.
func (*Echo) IsExist ¶
IsExist returns true if file is 1) accessible 2) exists. All other conditions returns false.
func (*Echo) IsReg ¶
IsReg returns true if path is a regular file. All other cases (errors) will return false.
func (*Echo) Mkdirs ¶
Mkdirs creates one or more space-separated directories using the optional filemods. If no mode is provided, it defaults to 0777. When mode is provided only modes[0] is applied.
func (*Echo) PathMatched ¶
PathMatched returns true if path matches shell file pattern
func (*Echo) PathSym ¶
PathSym returns the evaluated symbolic link for path. Returns empty if symbolic evaluation fails.
func (*Echo) Rel ¶
Rel returns path that is relative to base/target. Returns an empty path if error.
func (*Echo) Run ¶
Run parses and executes cmdStr and returns the result as a string. This uses RunProc and extracts the result as a string.
func (*Echo) RunProc ¶
func (e *Echo) RunProc(cmdStr string) *ProcResult
RunProc parses and executes cmdStr and returns a process result. Use this to have access to process result informoation.
func (*Echo) Split ¶
Split splits a space-separated (default) string into []string. An optional separator sep maybe provided as well.
func (*Echo) StartProc ¶
func (e *Echo) StartProc(cmdStr string) *ProcResult
StartProc concurrently starts a process
type ProcResult ¶
type ProcResult struct {
// contains filtered or unexported fields
}
ProcResult stores process info
func (*ProcResult) ExitCode ¶
func (p *ProcResult) ExitCode() int
ExitCode returns process exit code
func (*ProcResult) Exited ¶
func (p *ProcResult) Exited() bool
Exited returns true if process exits ok
func (*ProcResult) IsSuccess ¶
func (p *ProcResult) IsSuccess() bool
IsSuccess returns true if proc exit ok
func (*ProcResult) Out ¶
func (p *ProcResult) Out() io.Reader
Out surfaces an io.Reader for proc result
func (*ProcResult) SysTime ¶
func (p *ProcResult) SysTime() time.Duration
SysTime returns proc system cpu time
func (*ProcResult) UserTime ¶
func (p *ProcResult) UserTime() time.Duration
UserTime returns proc user cpu time
func (*ProcResult) Wait ¶
func (p *ProcResult) Wait()
Wait for associated process to complete. Any error can be accessed via p.Err()