From 428df5e39c0a696b71724237879a22a718a854a7 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 10 Nov 2016 22:06:08 -0800 Subject: [PATCH] cmd/go: don't set default GOPATH to GOROOT It will just cause confusion later as the go tool will say "warning: GOPATH set to GOROOT (%s) has no effect". Better to just leave GOPATH unset and get that warning instead. Change-Id: I78ff9e87fdf4bb0460f4f6d6ee76e1becaa3e7b0 Reviewed-on: https://go-review.googlesource.com/33105 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Russ Cox --- src/go/build/build.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/go/build/build.go b/src/go/build/build.go index 0801565f02..f6aabcb3af 100644 --- a/src/go/build/build.go +++ b/src/go/build/build.go @@ -264,7 +264,13 @@ func defaultGOPATH() string { env = "home" } if home := os.Getenv(env); home != "" { - return filepath.Join(home, "go") + def := filepath.Join(home, "go") + if def == runtime.GOROOT() { + // Don't set the default GOPATH to GOROOT, + // as that will trigger warnings from the go tool. + return "" + } + return def } return "" } -- 2.48.1