pathutil

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(path string) (string, error)

Abs returns an absolute representation of path, but handles case-insensitive filesystems as described in the comment on Getwd for the case where the path is relative and the cwd needs to be obtained

func ExpandHomeDir

func ExpandHomeDir(homeDir string, path string) (string, error)

ExpandHomeDir expands a given path to its absolute form, handling home directory

func GetDrive

func GetDrive(path string) string

GetDrive extracts the drive letter or UNC share from a path.

func Getwd

func Getwd() (string, error)

Getwd returns the current working directory, but handles case-insensitive filesystems (i.e. MacOS defaults) and returns the path with the casing as it appears when doing list dir syscalls. For example, on a case-insensitive filesystem, you can do "cd /FoO/bAr" and os.Getwd will return "/FoO/bAr", but if you do "ls /" you may see "fOO" and if you do "ls /fOO" you may see "BAR", which creates inconsistent paths depending on if you are using Getwd or walking the filesystem.

func LexicalRelativePath

func LexicalRelativePath(cwdPath, modPath string) (string, error)

LexicalRelativePath computes a relative path between the current working directory and modPath without relying on runtime.GOOS to estimate OS-specific separators. This is necessary as the code runs inside a Linux container, but the user might have specified a Windows-style modPath.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳