From 14c9f0a5a23f25f9f33ee3fd82be473a286c4962 Mon Sep 17 00:00:00 2001 From: rsteube Date: Sat, 9 Nov 2024 00:41:42 +0100 Subject: [PATCH] traverse: added golang --- pkg/traverse/golang.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 pkg/traverse/golang.go 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 +}