Documentation
¶
Index ¶
- func ExpandHomeDir(path string) (string, error)
- func ExpandPath(p string) string
- func IsWithin(p, dir string) bool
- func RelativeTo(p, baseDir string) string
- func ShortenHome(p string) string
- func ShortenHomeDir(p, homeDir string) string
- func ValidatePathInDirectory(path, allowedDir string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpandHomeDir ¶ added in v1.58.0
ExpandHomeDir expands a leading home-directory reference in a path. It expands "~", "~/...", and "~\\..." on Windows. Other tilde forms, such as "~user/...", are returned unchanged.
func ExpandPath ¶ added in v1.44.0
ExpandPath expands shell-like patterns in a file path:
- ~ or ~/ at the start is replaced with the user's home directory
- Environment variables like ${HOME} or $HOME are expanded
func RelativeTo ¶ added in v1.66.0
RelativeTo returns p relative to baseDir when both paths are absolute and filepath.Rel can compute a relative path. Otherwise it returns p cleaned.
func ShortenHome ¶ added in v1.66.0
ShortenHome replaces the current user's home directory prefix with "~".
func ShortenHomeDir ¶ added in v1.66.0
ShortenHomeDir replaces a leading homeDir prefix with "~".
func ValidatePathInDirectory ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.