cmd/go-contrib-init: fix get GOPATH env logic
Go runtime now uses user homedir+go (i.e. $HOME/go) if GOPATH environment variable is not set. Change-Id: I26d90e07976a5311ea19de8a6e2c63830b802882 Reviewed-on: https://go-review.googlesource.com/46234 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
63c6481f3b
commit
601a54bfa3
|
@ -12,6 +12,7 @@ import (
|
|||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go/build"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
@ -46,7 +47,7 @@ func detectrepo() string {
|
|||
return "go"
|
||||
}
|
||||
|
||||
for _, path := range filepath.SplitList(os.Getenv("GOPATH")) {
|
||||
for _, path := range filepath.SplitList(build.Default.GOPATH) {
|
||||
rightdir := filepath.Join(path, "src", "golang.org", "x")
|
||||
if strings.HasPrefix(wd, rightdir) {
|
||||
tail := wd[len(rightdir)+1:]
|
||||
|
@ -145,7 +146,7 @@ func checkWorkingDir() {
|
|||
}
|
||||
|
||||
func firstGoPath() string {
|
||||
list := filepath.SplitList(os.Getenv("GOPATH"))
|
||||
list := filepath.SplitList(build.Default.GOPATH)
|
||||
if len(list) < 1 {
|
||||
return ""
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue