diff options
Diffstat (limited to 'vendor/github.com/google/gops/internal/internal.go')
-rw-r--r-- | vendor/github.com/google/gops/internal/internal.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/vendor/github.com/google/gops/internal/internal.go b/vendor/github.com/google/gops/internal/internal.go index 80eac63f..ec63f918 100644 --- a/vendor/github.com/google/gops/internal/internal.go +++ b/vendor/github.com/google/gops/internal/internal.go @@ -6,12 +6,12 @@ package internal import ( "errors" - "fmt" "io/ioutil" "os" "os/user" "path/filepath" "runtime" + "strconv" "strings" ) @@ -22,9 +22,18 @@ func ConfigDir() (string, error) { return configDir, nil } + if osUserConfigDir := getOSUserConfigDir(); osUserConfigDir != "" { + return filepath.Join(osUserConfigDir, "gops"), nil + } + 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") @@ -45,7 +54,7 @@ func PIDFile(pid int) (string, error) { if err != nil { return "", err } - return fmt.Sprintf("%s/%d", gopsdir, pid), nil + return filepath.Join(gopsdir, strconv.Itoa(pid)), nil } func GetPort(pid int) (string, error) { |