Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecsInPath ¶
ExecsInPath returns a list of executables in the given path. The returned paths are absolute.
The given path should be an absolute path to a directory. If it's not a directory, the function will not proceed and return a nil slice.
lookalike accepts a function that returns true if the file name matches what we are expecting. Example:
func looksLikePip(name string) bool { var pipFileRegex = regexp.MustCompile(`^pip3(\d(\.\d\d?)?)?$`) return pipFileRegex.MatchString(name) }
func FilesInPath ¶ added in v0.1.0
func FilesInPath(path string, lookalike func(string) bool, additionalChecks ...func(fs.FileInfo) bool) ([]string, error)
FilesInPath returns a list of files in the given path. The returned paths are absolute.
The given path should be an absolute path to a directory. If it's not a directory, the function will not proceed and return a nil slice.
lookalike accepts a function that returns true if the file name matches what we are expecting. Example:
func looksLikePip(name string) bool { var pipFileRegex = regexp.MustCompile(`^pip3(\d(\.\d\d?)?)?$`) return pipFileRegex.MatchString(name) }
additionalChecks accepts a list of functions that returns true if the file meets the requirements. Example:
func IsExecutable(info fs.FileInfo) bool { return strings.ToLower(filepath.Ext(info.Name())) == ".exe" }
func IsDir ¶
IsDir returns true if the given path exists and is a directory. It delegates to os.Stat and FileInfo.IsDir.
func IsExecutable ¶
IsExecutable returns true if the given file info is executable. On Windows, it just checks if the file extension is ".exe" or not.
Types ¶
This section is empty.