This commit is contained in:
dpc 2025-03-10 13:26:31 +02:00 committed by GitHub
commit cd3dc8841c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {