]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: default to GO111MODULE=on
authorJay Conrod <jayconrod@google.com>
Tue, 15 Sep 2020 16:59:05 +0000 (12:59 -0400)
committerJay Conrod <jayconrod@google.com>
Mon, 21 Sep 2020 01:30:48 +0000 (01:30 +0000)
Fixes #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>

src/cmd/go/internal/modload/init.go
src/cmd/go/testdata/script/mod_enabled.txt
src/go/build/build.go

index 7a62436e3514ee7c34286c70e90cede28e3af064..9596368f00e873e6e17f1cf7f9b8eae1f1ab5f67 100644 (file)
@@ -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 {
@@ -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
index 10fa103fad391364b7fcc5632b65b6e066077d81..39f1ece8cb8eea2ce1e65715ed6dce0d681957b7 100644 (file)
@@ -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
@@ -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
index 39bc3591a7b0f74d1b5d1fa57768449c0f766747..6b75aad9cf6df223e344132b8505c99e96b2010e 100644 (file)
@@ -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