diff options
author | Michael Matloob <matloob@golang.org> | 2022-06-07 13:53:40 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2022-06-08 16:53:29 +0000 |
commit | 899f0a29c7be2bba3f8f0bc2987f7c2d70a6c4ec (patch) | |
tree | 3b938204c8a1514812b71e2dd7199454830130c7 | |
parent | f862280e30300017292b24a0fca088628d7b8065 (diff) | |
download | go-899f0a29c7be2bba3f8f0bc2987f7c2d70a6c4ec.tar.gz go-899f0a29c7be2bba3f8f0bc2987f7c2d70a6c4ec.zip |
cmd/go: enable module index by default
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>
-rw-r--r-- | src/cmd/go/internal/modindex/read.go | 13 | ||||
-rw-r--r-- | src/cmd/go/script_test.go | 1 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/cmd/go/internal/modindex/read.go b/src/cmd/go/internal/modindex/read.go index 0ed480fbd0..daa85762be 100644 --- a/src/cmd/go/internal/modindex/read.go +++ b/src/cmd/go/internal/modindex/read.go @@ -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} diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go index d1fe36ec21..04bc8d581a 100644 --- a/src/cmd/go/script_test.go +++ b/src/cmd/go/script_test.go @@ -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, |