Use os.UserHomeDir() instead of writing our own, but keep the fallback on Linux. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@@ -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.
- return os.Getenv(Key())
+ return home
}
// GetShortcutString returns the string that is shortcut to user's home directory