diff --git a/pkg/traverse/golang.go b/pkg/traverse/golang.go new file mode 100644 index 000000000..d7c3a8521 --- /dev/null +++ b/pkg/traverse/golang.go @@ -0,0 +1,22 @@ +package traverse + +import ( + "os" + "path/filepath" + "strings" +) + +func GoBinDir(tc Context) (dir string, err error) { + if path, ok := tc.LookupEnv("GOPATH"); ok { + dir = strings.Split(path, string(os.PathListSeparator))[0] + } + + if dir == "" { + if dir, err = UserHomeDir(tc); err != nil { + return "", err + } + dir += "/go" + } + + return filepath.ToSlash(dir) + "/bin", nil +}