-
Notifications
You must be signed in to change notification settings - Fork 17.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: proceed with GOPATH unset if the command doesn't use it
For #43938 Change-Id: I0937b9bb6de3d29d7242ee61f053d4803277dc0f Reviewed-on: https://go-review.googlesource.com/c/go/+/351329 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
- Loading branch information
Bryan C. Mills
committed
Sep 22, 2021
1 parent
ccf140f
commit 5ee32ff
Showing
4 changed files
with
37 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,11 +31,18 @@ env GOPATH= | |
go env GOMODCACHE | ||
stdout $HOME[/\\]go[/\\]pkg[/\\]mod | ||
|
||
# If GOMODCACHE isn't set and GOPATH starts with the path list separator, it's an error. | ||
# If GOMODCACHE isn't set and GOPATH starts with the path list separator, | ||
# GOMODCACHE is empty and any command that needs it errors out. | ||
env GOMODCACHE= | ||
env GOPATH=${:}$WORK/this/is/ignored | ||
! go env GOMODCACHE | ||
stderr 'missing \$GOPATH' | ||
|
||
go env GOMODCACHE | ||
stdout '^$' | ||
! stdout . | ||
! stderr . | ||
|
||
! go mod download rsc.io/[email protected] | ||
stderr '^go: module cache not found: neither GOMODCACHE nor GOPATH is set$' | ||
|
||
# If GOMODCACHE isn't set and GOPATH has multiple elements only the first is used. | ||
env GOMODCACHE= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# https://golang.org/issue/43938: 'go build' should succeed | ||
# if GOPATH and the variables needed for its default value | ||
# are all unset but not relevant to the specific command. | ||
|
||
env HOME='' | ||
env home='' | ||
env GOPATH='' | ||
|
||
go list -deps main.go | ||
stdout '^io$' | ||
|
||
-- main.go -- | ||
package main | ||
|
||
import _ "io" |