path

package
v1.66.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandHomeDir added in v1.58.0

func ExpandHomeDir(path string) (string, error)

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

func ExpandPath(p string) string

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 IsWithin added in v1.66.0

func IsWithin(p, dir string) bool

IsWithin reports whether p is equal to dir or contained by dir.

func RelativeTo added in v1.66.0

func RelativeTo(p, baseDir string) string

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

func ShortenHome(p string) string

ShortenHome replaces the current user's home directory prefix with "~".

func ShortenHomeDir added in v1.66.0

func ShortenHomeDir(p, homeDir string) string

ShortenHomeDir replaces a leading homeDir prefix with "~".

func ValidatePathInDirectory

func ValidatePathInDirectory(path, allowedDir string) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL