Documentation ¶
Index ¶
- Variables
- func AsyncMultiWriter(limit int, writers ...io.Writer) io.Writer
- func CleanOldDirs() error
- func Close(closer io.Closer, err *error)
- func CopyDir(fromPath, toPath string, includeDirs bool, excludeNames []string) error
- func CopyFile(dst, src string) (err error)
- func CreateDirIfNotExist(path string) error
- func CreateFilePath(localPath, fileName string) (string, error)
- func CreateRandomLenFile(maxLen int, filesDir string, prefix string) string
- func CreateTempDir() (string, error)
- func DoubleWinPathSeparator(filePath string) string
- func DownloadFile(downloadTo string, fromUrl string) (err error)
- func FindFileInDirAndParents(dirPath, fileName string) (string, error)
- func GetFileAndDirFromPath(path string) (fileName, dir string)
- func GetFileContentAndInfo(filePath string) (fileContent []byte, fileInfo os.FileInfo, err error)
- func GetFileInfo(path string, followSymlink bool) (fileInfo os.FileInfo, err error)
- func GetFileSeparator() string
- func IsDirExists(path string, followSymlink bool) (bool, error)
- func IsFileExists(path string, followSymlink bool) (bool, error)
- func IsFileSymlink(file os.FileInfo) bool
- func IsPathExists(path string) bool
- func IsPathSymlink(path string) bool
- func ListFiles(path string, includeDirs bool) ([]string, error)
- func ListFilesByFilterFunc(path string, filterFunc func(filePath string) (bool, error)) ([]string, error)
- func MoveDir(fromPath, toPath string) error
- func MoveFile(sourcePath, destPath string) (err error)
- func ReadNLines(path string, total int) (lines []string, err error)
- func RemoveTempDir(dirPath string) error
- 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 Unmarshal(filePath string, loadTarget interface{}) (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 ErrShortWrite = errors.New("the number of bytes written is less than the length of the input")
var ErrSkipDir = errors.New("skip this directory")
Functions ¶
func AsyncMultiWriter ¶ added in v1.7.0
AsyncMultiWriter creates a writer that duplicates its writes to all the provided writers asynchronous
func CleanOldDirs ¶ added in v1.7.3
func CleanOldDirs() error
Old runs/tests may leave junk at temp dir. Each temp file/Dir is named with prefix+timestamp, search for all temp files/dirs that match the common prefix and validate their timestamp.
func CopyDir ¶ added in v1.7.3
Copy directory content from one path to another. includeDirs means to copy also the dirs if presented in the src folder. excludeNames - Skip files/dirs in the src folder that match names in provided slice. ONLY excludes first layer (only in src folder).
func CreateDirIfNotExist ¶ added in v1.7.3
func CreateFilePath ¶ added in v1.7.3
func CreateRandomLenFile ¶
Create a temp file with the requested prefix at the provided dir. File length and contents are random, up to the requested max length.
func CreateTempDir ¶ added in v1.7.3
CreateTempDir creates a temporary directory and returns its path.
func DoubleWinPathSeparator ¶ added in v1.7.3
func DownloadFile ¶ added in v1.7.3
func FindFileInDirAndParents ¶ added in v1.7.3
FindFileInDirAndParents looks for a file named fileName in dirPath and its parents, and returns the path of the directory where it was found. dirPath must be a full path.
func GetFileAndDirFromPath ¶ added in v1.7.3
Return the file's name and dir of a given path by finding the index of the last separator in the path. Support separators : "/" , "\\" and "\\\\"
func GetFileContentAndInfo ¶ added in v1.7.3
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 GetFileSeparator ¶ added in v1.7.3
func GetFileSeparator() string
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 IsFileExists ¶ added in v1.7.3
Checxk if path points at a file. If path points at a symlink and `followSymlink == false`, function will return `true` regardless of the symlink target
func IsFileSymlink ¶ added in v1.1.2
func IsPathExists ¶ added in v1.7.3
IsPathExists checks if a path exists.
func IsPathSymlink ¶ added in v1.1.2
func ListFilesByFilterFunc ¶ added in v1.7.3
func ListFilesByFilterFunc(path string, filterFunc func(filePath string) (bool, error)) ([]string, error)
Return all files in the specified path who satisfy the filter func. Not recursive.
func MoveFile ¶ added in v1.7.3
GoLang: os.Rename() give error "invalid cross-device link" for Docker container with Volumes. MoveFile(source, destination) will work moving file between folders Therefore, we are using our own implementation (MoveFile) in order to rename files.
func ReadNLines ¶ added in v1.7.3
strip '\n' or read until EOF, return error if read error readNLines reads up to 'total' number of lines separated by \n.
func RemoveTempDir ¶ added in v1.7.3
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