From 71c4255d55eaf43b37462b26f931941cccd2c259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=81ukasiewicz?= Date: Sat, 29 Feb 2020 23:24:56 +0100 Subject: [PATCH] Check $XDG_CONFIG_HOME before falling to ~/.config (#99) --- internal/internal.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/internal.go b/internal/internal.go index 80eac63..bbd233f 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -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")