From 9fb62cb011a307d4a59272640c2b07351f13ad9e Mon Sep 17 00:00:00 2001 From: James Harris Date: Tue, 19 Dec 2017 09:08:53 +1000 Subject: [PATCH] Add naive support for multiple gopaths (fixes #52) --- CHANGELOG.md | 1 + src/grit/pathutil/golang.go | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1639076..8ce0433 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **[IMPROVED]** Interactive clone directory prompts now order the options by their distance from the current working directory - **[IMPROVED]** Interactive clone directory prompts now indicate if one of the options is the current working directory - **[IMPROVED]** Add `open` as an alias for the `browse` command +- **[FIX]** Naive support for multiple `$GOPATH` directories (grit always used the first one in the list) ## 0.6.8 (2017-12-04) diff --git a/src/grit/pathutil/golang.go b/src/grit/pathutil/golang.go index ee9883c..3c7c778 100644 --- a/src/grit/pathutil/golang.go +++ b/src/grit/pathutil/golang.go @@ -3,13 +3,15 @@ package pathutil import ( "os" "path" + "path/filepath" ) // GoPath returns the current user's $GOPATH directory. func GoPath() (string, error) { - dir := os.Getenv("GOPATH") - if dir != "" { - return dir, nil + p := os.Getenv("GOPATH") + if p != "" { + dirs := filepath.SplitList(p) + return dirs[0], nil } home, err := HomeDir()