1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Revert "Call the os.UserHomeDir in Home"

This reverts commit d3b6bc503a583bd2d841a9fba439b9f7e4056ff0.
This commit is contained in:
Tim Scheuermann 2019-10-11 23:36:21 +02:00
parent d3b6bc503a
commit 270daf31ea

View File

@ -6,7 +6,7 @@ package utils
import (
"errors"
"os"
"os/user"
"path/filepath"
)
@ -37,5 +37,14 @@ func ExpandHomeDir(path string) (string, error) {
// Home returns the home directory for the executing user.
// An error is returned if a home directory cannot be detected.
func Home() (string, error) {
return os.UserHomeDir()
currentUser, err := user.Current()
if err != nil {
return "", err
}
if currentUser.HomeDir == "" {
return "", errors.New("cannot find user-specific home dir")
}
return currentUser.HomeDir, nil
}