Skip to content

Commit 899f0a2

Browse files
matloobrsc
authored andcommitted
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 <[email protected]> Reviewed-by: Russ Cox <[email protected]> Reviewed-by: Michael Matloob <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent f862280 commit 899f0a2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/cmd/go/internal/modindex/read.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"runtime"
2323
"runtime/debug"
2424
"sort"
25-
"strconv"
2625
"strings"
2726
"sync"
2827
"unsafe"
@@ -40,7 +39,15 @@ import (
4039
// It will be removed before the release.
4140
// TODO(matloob): Remove enabled once we have more confidence on the
4241
// module index.
43-
var enabled, _ = strconv.ParseBool(os.Getenv("GOINDEX"))
42+
var enabled = func() bool {
43+
debug := strings.Split(os.Getenv("GODEBUG"), ",")
44+
for _, f := range debug {
45+
if f == "goindex=0" {
46+
return false
47+
}
48+
}
49+
return true
50+
}()
4451

4552
// ModuleIndex represents and encoded module index file. It is used to
4653
// 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) {
125132
data, _, err := cache.Default().GetMmap(id)
126133
if err != nil {
127134
// Couldn't read from modindex. Assume we couldn't read from
128-
// the index because the module has't been indexed yet.
135+
// the index because the module hasn't been indexed yet.
129136
data, err = indexModule(modroot)
130137
if err != nil {
131138
return result{nil, err}

src/cmd/go/script_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ func (ts *testScript) setup() {
170170
"GOCACHE=" + testGOCACHE,
171171
"GODEBUG=" + os.Getenv("GODEBUG"),
172172
"GOEXE=" + cfg.ExeSuffix,
173-
"GOINDEX=true",
174173
"GOOS=" + runtime.GOOS,
175174
"GOPATH=" + filepath.Join(ts.workdir, "gopath"),
176175
"GOPROXY=" + proxyURL,

0 commit comments

Comments
 (0)