pkg/homedir: use os.UserHomeDir()
Use os.UserHomeDir() instead of writing our own, but keep the fallback on Linux. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
db381fb21b
commit
0aca7f2a0d
2 changed files with 3 additions and 2 deletions
pkg/homedir
|
@ -22,7 +22,7 @@ func Key() string {
|
|||
//
|
||||
// If needing to do nss lookups, do not disable cgo or set osusergo.
|
||||
func Get() string {
|
||||
home := os.Getenv(Key())
|
||||
home, _ := os.UserHomeDir()
|
||||
if home == "" {
|
||||
if u, err := user.Current(); err == nil {
|
||||
return u.HomeDir
|
||||
|
|
|
@ -14,7 +14,8 @@ func Key() string {
|
|||
// environment variables depending on the target operating system.
|
||||
// Returned path should be used with "path/filepath" to form new paths.
|
||||
func Get() string {
|
||||
return os.Getenv(Key())
|
||||
home, _ := os.UserHomeDir()
|
||||
return home
|
||||
}
|
||||
|
||||
// GetShortcutString returns the string that is shortcut to user's home directory
|
||||
|
|
Loading…
Add table
Reference in a new issue