// which is not what most people want when they do it.
if gopath := os.Getenv("GOPATH"); gopath == runtime.GOROOT() {
fmt.Fprintf(os.Stderr, "warning: GOPATH set to GOROOT (%s) has no effect\n", gopath)
+ } else {
+ for _, p := range strings.Split(gopath, ":") {
+ if build.IsLocalImport(p) {
+ fmt.Fprintf(os.Stderr, "go: GOPATH entry is relative; must be absolute path: %q.\nRun 'go help gopath' for usage.\n", p)
+ os.Exit(2)
+ }
+ }
}
for _, cmd := range commands {
ok=false
fi
+# Reject relative paths in GOPATH.
+if GOPATH=. ./testgo build testdata/src/go-cmd-test/helloworld.go; then
+ echo 'GOPATH="." go build should have failed, did not'
+ ok=false
+fi
+
+if GOPATH=:$(pwd)/testdata:. ./testgo build go-cmd-test; then
+ echo 'GOPATH=":$(pwd)/testdata:." go build should have failed, did not'
+ ok=false
+fi
+
if $ok; then
echo PASS
else