1
0
mirror of https://github.com/golang/go synced 2024-11-11 20:20:23 -07:00

build: set GOPATH consistently in run.bash, run.bat, run.rc

We used to clear GOPATH in all the build scripts.
Clearing GOPATH is misleading at best, since you just end up
with the default GOPATH (%USERPROFILE%\go on Windows).
Unless that's your GOROOT, in which case you end up with a
fatal error from the go command (#43938).

run.bash changed to setting GOPATH=/dev/null, which has no
clear analogue on Windows.

run.rc still clears GOPATH.

Change them all to set GOPATH to a non-existent directory
/nonexist-gopath or c:\nonexist-gopath.

Change-Id: I51edd66d37ff6a891b0d0541d91ecba97fbbb03d
Reviewed-on: https://go-review.googlesource.com/c/go/+/288818
Trust: Russ Cox <rsc@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Russ Cox 2021-01-26 21:14:43 -05:00
parent a1222b7535
commit bb6efb9609
3 changed files with 6 additions and 17 deletions

View File

@ -23,15 +23,7 @@ fi
eval $(../bin/go env) eval $(../bin/go env)
export GOROOT # The api test requires GOROOT to be set, so set it to match ../bin/go. export GOROOT # The api test requires GOROOT to be set, so set it to match ../bin/go.
export GOPATH=/nonexist-gopath
# We disallow local import for non-local packages, if $GOROOT happens
# to be under $GOPATH, then some tests below will fail. $GOPATH needs
# to be set to a non-empty string, else Go will set a default value
# that may also conflict with $GOROOT. The $GOPATH value doesn't need
# to point to an actual directory, it just needs to pass the semantic
# checks performed by Go. Use $GOROOT to define $GOPATH so that we
# don't blunder into a user-defined symbolic link.
export GOPATH=/dev/null
unset CDPATH # in case user has it set unset CDPATH # in case user has it set
export GOBIN=$GOROOT/bin # Issue 14340 export GOBIN=$GOROOT/bin # Issue 14340

View File

@ -18,9 +18,7 @@ setlocal
set GOBUILDFAIL=0 set GOBUILDFAIL=0
:: we disallow local import for non-local packages, if %GOROOT% happens set GOPATH=c:\nonexist-gopath
:: to be under %GOPATH%, then some tests below will fail
set GOPATH=
:: Issue 14340: ignore GOBIN during all.bat. :: Issue 14340: ignore GOBIN during all.bat.
set GOBIN= set GOBIN=
set GOFLAGS= set GOFLAGS=

View File

@ -12,10 +12,9 @@ if(! test -f ../bin/go){
eval `{../bin/go env} eval `{../bin/go env}
GOPATH = () # we disallow local import for non-local packages, if $GOROOT happens GOPATH=/nonexist-gopath
# to be under $GOPATH, then some tests below will fail GOBIN=() # Issue 14340
GOBIN = () # Issue 14340 GOFLAGS=()
GOFLAGS = () GO111MODULE=()
GO111MODULE = ()
exec ../bin/go tool dist test -rebuild $* exec ../bin/go tool dist test -rebuild $*