]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: enable module index by default
authorMichael Matloob <matloob@golang.org>
Tue, 7 Jun 2022 17:53:40 +0000 (13:53 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 8 Jun 2022 16:53:29 +0000 (16:53 +0000)
This changes the module index to be enabled by default, rather than
disabled by default. The index can still be disabled by setting
GODEBUG=index=0.

Fixes #53290.

Change-Id: Ic3728fc69d96bb6ef56b56e8c9f2dce35f2923cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/410821
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
src/cmd/go/internal/modindex/read.go
src/cmd/go/script_test.go

index 0ed480fbd00dc59d5a2b5982307ee558df387421..daa85762be00cc3430979614670d03f52125dc77 100644 (file)
@@ -22,7 +22,6 @@ import (
        "runtime"
        "runtime/debug"
        "sort"
-       "strconv"
        "strings"
        "sync"
        "unsafe"
@@ -40,7 +39,15 @@ import (
 // It will be removed before the release.
 // TODO(matloob): Remove enabled once we have more confidence on the
 // module index.
-var enabled, _ = strconv.ParseBool(os.Getenv("GOINDEX"))
+var enabled = func() bool {
+       debug := strings.Split(os.Getenv("GODEBUG"), ",")
+       for _, f := range debug {
+               if f == "goindex=0" {
+                       return false
+               }
+       }
+       return true
+}()
 
 // ModuleIndex represents and encoded module index file. It is used to
 // do the equivalent of build.Import of packages in the module and answer other
@@ -125,7 +132,7 @@ func openIndex(modroot string, ismodcache bool) (*ModuleIndex, error) {
                data, _, err := cache.Default().GetMmap(id)
                if err != nil {
                        // Couldn't read from modindex. Assume we couldn't read from
-                       // the index because the module has't been indexed yet.
+                       // the index because the module hasn't been indexed yet.
                        data, err = indexModule(modroot)
                        if err != nil {
                                return result{nil, err}
index d1fe36ec21fcfb84a7bd0a8dcdd68e9252813c7b..04bc8d581a33a350a2d2dc472b7ef8795947f15a 100644 (file)
@@ -170,7 +170,6 @@ func (ts *testScript) setup() {
                "GOCACHE=" + testGOCACHE,
                "GODEBUG=" + os.Getenv("GODEBUG"),
                "GOEXE=" + cfg.ExeSuffix,
-               "GOINDEX=true",
                "GOOS=" + runtime.GOOS,
                "GOPATH=" + filepath.Join(ts.workdir, "gopath"),
                "GOPROXY=" + proxyURL,