homedir

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCannotExpandUser 表示无法展开用户特定的主目录
	ErrCannotExpandUser = errors.New("cannot expand user-specific home dir")
	// ErrBlankOutput 表示读取主目录时得到空白输出
	ErrBlankOutput = errors.New("blank output when reading home directory")
	// ErrMissingWindowsEnv 表示 Windows 环境变量缺失
	ErrMissingWindowsEnv = errors.New("HOMEDRIVE, HOMEPATH, or USERPROFILE are blank")
)

Functions

func Dir

func Dir() (string, error)

Dir 返回执行用户的主目录。

它使用特定于操作系统的方法来发现主目录。 如果无法检测到主目录,则返回错误。

func Expand

func Expand(path string) (string, error)

Expand 如果路径以 `~` 为前缀,则将路径扩展为包含主目录。 如果不以 `~` 为前缀,则按原样返回路径。

func Reset

func Reset()

Reset 清除缓存,强制下一次调用 Dir 重新检测主目录。 这通常不需要调用,但在测试中如果通过 HOME 环境变量 或其他方式修改主目录时可能会有用。

Types

This section is empty.

Jump to

Keyboard shortcuts

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