Skip to content

Commit

Permalink
cmd/go: default to GO111MODULE=on
Browse files Browse the repository at this point in the history
Fixes golang#41330

Change-Id: Ib66087ac5e1eb827694915f21c32c4d88e1b9a7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/255052
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
  • Loading branch information
Jay Conrod committed Sep 21, 2020
1 parent 331614c commit b4ea672
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/cmd/go/internal/modload/init.go
Expand Up @@ -120,9 +120,9 @@ func Init() {
switch env {
default:
base.Fatalf("go: unknown environment setting GO111MODULE=%s", env)
case "auto", "":
case "auto":
mustUseModules = ForceUseModules
case "on":
case "on", "":
mustUseModules = true
case "off":
if ForceUseModules {
Expand Down Expand Up @@ -257,9 +257,9 @@ func WillBeEnabled() bool {
// exits, so it can't call this function directly.
env := cfg.Getenv("GO111MODULE")
switch env {
case "on":
case "on", "":
return true
case "auto", "":
case "auto":
break
default:
return false
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/go/testdata/script/mod_enabled.txt
Expand Up @@ -25,7 +25,7 @@ cd $GOPATH/foo/bar/baz
go env GOMOD
stdout foo[/\\]go.mod

# GO111MODULE unset should be equivalent to auto.
# GO111MODULE unset should be equivalent to on.
env GO111MODULE=

cd $GOPATH/src/x/y/z
Expand All @@ -34,7 +34,7 @@ stdout $GOPATH[/\\]src[/\\]x[/\\]y[/\\]z[/\\]go.mod

cd $GOPATH/src/x/y
go env GOMOD
! stdout .
stdout 'NUL|/dev/null'

# GO111MODULE=on should trigger everywhere
env GO111MODULE=on
Expand Down
4 changes: 2 additions & 2 deletions src/go/build/build.go
Expand Up @@ -1072,9 +1072,9 @@ func (ctxt *Context) importGo(p *Package, path, srcDir string, mode ImportMode)
}
}

// Unless GO111MODULE=on, look to see if there is a go.mod.
// If GO111MODULE=auto, look to see if there is a go.mod.
// Since go1.13, it doesn't matter if we're inside GOPATH.
if go111Module != "on" {
if go111Module == "auto" {
var (
parent string
err error
Expand Down

0 comments on commit b4ea672

Please sign in to comment.