Check $HOME as last

This commit is contained in:
a1lu 2024-03-30 23:21:42 +01:00
parent d2b7c80369
commit 956598c427
1 changed files with 4 additions and 5 deletions

View File

@ -32,16 +32,15 @@ const NbBytesWords = 4
// Get or create home directory
func GetConfigDir() (homedir string, err error) {
homedir, err = os.UserHomeDir()
if err != nil {
return
}
if envHomedir, isSet := os.LookupEnv("CROC_CONFIG_DIR"); isSet {
homedir = envHomedir
} else if xdgConfigHome, isSet := os.LookupEnv("XDG_CONFIG_HOME"); isSet {
homedir = path.Join(xdgConfigHome, "croc")
} else {
homedir, err = os.UserHomeDir()
if err != nil {
return
}
homedir = path.Join(homedir, ".config", "croc")
}