diff --git a/btcutil/appdata.go b/btcutil/appdata.go index b6c63b9a..8baf996f 100644 --- a/btcutil/appdata.go +++ b/btcutil/appdata.go @@ -29,18 +29,14 @@ func appDataDir(goos, appName string, roaming bool) string { appNameUpper := string(unicode.ToUpper(rune(appName[0]))) + appName[1:] appNameLower := string(unicode.ToLower(rune(appName[0]))) + appName[1:] - // Get the OS specific home directory via the Go standard lib. var homeDir string - usr, err := user.Current() - if err == nil { - homeDir = usr.HomeDir - } + // If HOME is set, use it + homeDir = os.Getenv("HOME") - // Fall back to standard HOME environment variable that works - // for most POSIX OSes if the directory from the Go standard - // lib failed. + // If not, Get the OS specific home directory via the Go standard lib. + usr, err := user.Current() if err != nil || homeDir == "" { - homeDir = os.Getenv("HOME") + homeDir = usr.HomeDir } switch goos {