From 096692c69384b40db6564a0a7003320232330ebb 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 | 23 +++++++++++++++++++++++ 1 file changed, 23 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..a1de82843 --- /dev/null +++ b/pkg/traverse/golang.go @@ -0,0 +1,23 @@ +package traverse + +import ( + "os" + "path/filepath" + "strings" +) + +// GoBinDir TODO experimental +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 +}