Documentation
¶
Index ¶
- func ChangeStripExtension(fp, newext string) string
- func CurLeafDir() (string, error)
- func FilepathLeaf(s string) string
- func FilterFilepaths(paths []string, inclExists, inclNotExists, inclFiles, inclDirs bool) []string
- func IsAbsAny(path string) bool
- func NormalizePath(p string) string
- func Trim(file string) string
- func TrimExt(path string) string
- func TrimLeft(file string) string
- func TrimRight(file string) string
- func UserToAbsolute(file string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangeStripExtension ¶ added in v0.64.5
func CurLeafDir ¶
CurLeafDir returns the leaf dir of a nested directory.
func FilepathLeaf ¶
FilepathLeaf returns the last element of a path.
func FilterFilepaths ¶
FilterFilepaths filters a slice of filepaths using various options.
func IsAbsAny ¶ added in v0.74.6
IsAbsAny returns true if the path is absolute on any platform. Unlike filepath.IsAbs, this function recognizes both Unix-style paths (starting with /) and Windows-style paths (starting with drive letter like C:\) regardless of the current operating system.
This is useful when handling paths that may come from different platforms, such as in cross-platform tools, SARIF output, or configuration files.
Examples:
IsAbsAny("/Users/test/file.txt") // true (Unix absolute)
IsAbsAny("C:\\Users\\test\\file.txt") // true (Windows absolute)
IsAbsAny("C:/Users/test/file.txt") // true (Windows with forward slashes)
IsAbsAny("relative/path.txt") // false
IsAbsAny("./relative/path.txt") // false
func NormalizePath ¶ added in v0.74.2
NormalizePath converts a file path to use forward slashes for consistent cross-platform comparison. This is useful when comparing paths that may come from different sources (e.g., Unix-style paths in config files on Windows).
The path is first cleaned using filepath.Clean, then all backslashes are converted to forward slashes.
func UserToAbsolute ¶
UserToAbsolute converts ~ directories to absolute directories in filepaths. This is useful because ~ cannot be resolved by ioutil.ReadFile().
Types ¶
This section is empty.