1
0
mirror of https://github.com/google/gops.git synced 2024-11-27 08:31:17 +02:00

Check $XDG_CONFIG_HOME before falling to ~/.config (#99)

This commit is contained in:
Jakub Łukasiewicz 2020-02-29 23:24:56 +01:00 committed by GitHub
parent 59c8be2ead
commit 71c4255d55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,6 +25,11 @@ func ConfigDir() (string, error) {
if runtime.GOOS == "windows" {
return filepath.Join(os.Getenv("APPDATA"), "gops"), nil
}
if xdgConfigDir := os.Getenv("XDG_CONFIG_HOME"); xdgConfigDir != "" {
return filepath.Join(xdgConfigDir, "gops"), nil
}
homeDir := guessUnixHomeDir()
if homeDir == "" {
return "", errors.New("unable to get current user home directory: os/user lookup failed; $HOME is empty")