mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Revert "Revert "Call the os.UserHomeDir in Home""
This reverts commit 270daf31ea007147e1b04770e501688472750a7e.
This commit is contained in:
parent
270daf31ea
commit
226796099c
@ -6,7 +6,7 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"os/user"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,14 +37,5 @@ func ExpandHomeDir(path string) (string, error) {
|
|||||||
// Home returns the home directory for the executing user.
|
// Home returns the home directory for the executing user.
|
||||||
// An error is returned if a home directory cannot be detected.
|
// An error is returned if a home directory cannot be detected.
|
||||||
func Home() (string, error) {
|
func Home() (string, error) {
|
||||||
currentUser, err := user.Current()
|
return os.UserHomeDir()
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
if currentUser.HomeDir == "" {
|
|
||||||
return "", errors.New("cannot find user-specific home dir")
|
|
||||||
}
|
|
||||||
|
|
||||||
return currentUser.HomeDir, nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user