Documentation ¶
Index ¶
- Variables
- func Close(closer io.Closer, err *error)
- func CreateRandomLenFile(maxLen int, filesDir string, prefix string) string
- func GetFileInfo(path string, followSymlink bool) (fileInfo os.FileInfo, err error)
- func IsDirExists(path string, followSymlink bool) (bool, error)
- func IsFileSymlink(file os.FileInfo) bool
- func IsPathSymlink(path string) bool
- func RunCmd(config CmdConfig) error
- func RunCmdOutput(config CmdConfig) (string, error)
- func RunCmdWithOutputParser(config CmdConfig, prompt bool, regExpStruct ...*CmdOutputPattern) (stdOut string, errorOut string, exitOk bool, err error)
- func Walk(root string, walkFn WalkFunc, walkIntoDirSymlink bool) error
- type CmdConfig
- type CmdOutputPattern
- type Command
- type RandFile
- type Stat
- type WalkFunc
Constants ¶
This section is empty.
Variables ¶
var ErrSkipDir = errors.New("skip this directory")
Functions ¶
func CreateRandomLenFile ¶
func GetFileInfo ¶ added in v1.1.2
Get the file info of the file in path. If path points at a symlink and `followSymlink == false`, return the file info of the symlink instead
func IsDirExists ¶ added in v1.1.2
Check if path points at a directory. If path points at a symlink and `followSymlink == false`, function will return `false` regardless of the symlink target
func IsFileSymlink ¶ added in v1.1.2
func IsPathSymlink ¶ added in v1.1.2
func RunCmdOutput ¶ added in v1.0.3
Executes an external process and returns its output. If the returned output is not needed, use the RunCmd function instead , for better performance.
func RunCmdWithOutputParser ¶ added in v1.0.3
func RunCmdWithOutputParser(config CmdConfig, prompt bool, regExpStruct ...*CmdOutputPattern) (stdOut string, errorOut string, exitOk bool, err error)
Executes the command and captures the output. Analyze each line to match the provided regex. Returns the complete stdout output of the command.
Types ¶
type CmdConfig ¶ added in v1.0.3
type CmdConfig interface { GetCmd() *exec.Cmd GetEnv() map[string]string GetStdWriter() io.WriteCloser GetErrWriter() io.WriteCloser }
type CmdOutputPattern ¶ added in v1.0.3
type CmdOutputPattern struct { RegExp *regexp.Regexp MatchedResults []string Line string ExecFunc func(pattern *CmdOutputPattern) (string, error) }
RegExp - The regexp that the line will be searched upon. MatchedResults - The slice result that was found by the regexp Line - The output line from the external process ExecFunc - The function to execute
type Command ¶ added in v1.3.2
type Command struct { Executable string CmdName string CmdArgs []string Dir string StrWriter io.WriteCloser ErrWriter io.WriteCloser }
func NewCommand ¶ added in v1.3.2
func (*Command) GetErrWriter ¶ added in v1.3.2
func (config *Command) GetErrWriter() io.WriteCloser
func (*Command) GetStdWriter ¶ added in v1.3.2
func (config *Command) GetStdWriter() io.WriteCloser