Skip to content

Commit b4ea672

Browse files
author
Jay Conrod
committed
cmd/go: default to GO111MODULE=on
Fixes #41330 Change-Id: Ib66087ac5e1eb827694915f21c32c4d88e1b9a7e Reviewed-on: https://go-review.googlesource.com/c/go/+/255052 Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> Trust: Jay Conrod <[email protected]> Trust: Bryan C. Mills <[email protected]>
1 parent 331614c commit b4ea672

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/cmd/go/internal/modload/init.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ func Init() {
120120
switch env {
121121
default:
122122
base.Fatalf("go: unknown environment setting GO111MODULE=%s", env)
123-
case "auto", "":
123+
case "auto":
124124
mustUseModules = ForceUseModules
125-
case "on":
125+
case "on", "":
126126
mustUseModules = true
127127
case "off":
128128
if ForceUseModules {
@@ -257,9 +257,9 @@ func WillBeEnabled() bool {
257257
// exits, so it can't call this function directly.
258258
env := cfg.Getenv("GO111MODULE")
259259
switch env {
260-
case "on":
260+
case "on", "":
261261
return true
262-
case "auto", "":
262+
case "auto":
263263
break
264264
default:
265265
return false

src/cmd/go/testdata/script/mod_enabled.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ cd $GOPATH/foo/bar/baz
2525
go env GOMOD
2626
stdout foo[/\\]go.mod
2727

28-
# GO111MODULE unset should be equivalent to auto.
28+
# GO111MODULE unset should be equivalent to on.
2929
env GO111MODULE=
3030

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

3535
cd $GOPATH/src/x/y
3636
go env GOMOD
37-
! stdout .
37+
stdout 'NUL|/dev/null'
3838

3939
# GO111MODULE=on should trigger everywhere
4040
env GO111MODULE=on

src/go/build/build.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,9 +1072,9 @@ func (ctxt *Context) importGo(p *Package, path, srcDir string, mode ImportMode)
10721072
}
10731073
}
10741074

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

0 commit comments

Comments
 (0)