Skip to content

Commit

Permalink
Merge pull request #1056 from carapace-sh/traverse-fix-gobindir
Browse files Browse the repository at this point in the history
traverse: fix GoBinDir
  • Loading branch information
rsteube authored Nov 9, 2024
2 parents 45ee47a + 8404549 commit 6ab8f31
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/traverse/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (

// GoBinDir TODO experimental
func GoBinDir(tc Context) (dir string, err error) {
if path, ok := tc.LookupEnv("GOBIN"); ok {
return filepath.ToSlash(path), nil
}

if path, ok := tc.LookupEnv("GOPATH"); ok {
dir = strings.Split(path, string(os.PathListSeparator))[0]
}
Expand All @@ -16,8 +20,8 @@ func GoBinDir(tc Context) (dir string, err error) {
if dir, err = UserHomeDir(tc); err != nil {
return "", err
}
dir += "/go"
dir = filepath.Join(dir, "go")
}

return filepath.ToSlash(dir) + "/bin", nil
return filepath.ToSlash(filepath.Join(dir, "bin")), nil
}

0 comments on commit 6ab8f31

Please sign in to comment.