Skip to content

Latest commit

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

homedir

用于检测用户的主目录的Go库

用法

go get github.com/go-basic/homedir

用法非常简单,只需调用' homedir.Dir() '来获取用户主目录

使用' homedir.Expand() '将路径中的' ~ '展开到home目录中。

如: HOME=/custom/path/

homedir.Expand("~/foo/bar") 输出 /custom/path/foo/bar

示例

package main
import (
"fmt""github.com/go-basic/homedir"
)
funcmain() {
dir,err:=homedir.Dir()
iferr!=nil {
panic(err)
}
fmt.Println(dir)
foo,_:=homedir.Expand("~/foo")
fmt.Println(foo)
}

About

用于检测用户的主目录的Go库

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages