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:] appNameUpper := string(unicode.ToUpper(rune(appName[0]))) + appName[1:]
appNameLower := string(unicode.ToLower(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 var homeDir string
usr, err := user.Current() // If HOME is set, use it
if err == nil { homeDir = os.Getenv("HOME")
homeDir = usr.HomeDir
}
// Fall back to standard HOME environment variable that works // If not, Get the OS specific home directory via the Go standard lib.
// for most POSIX OSes if the directory from the Go standard usr, err := user.Current()
// lib failed.
if err != nil || homeDir == "" { if err != nil || homeDir == "" {
homeDir = os.Getenv("HOME") homeDir = usr.HomeDir
} }
switch goos { switch goos {