mirror of https://github.com/golang/go.git
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>
This commit is contained in:
parent
f862280e30
commit
899f0a29c7
|
|
@ -22,7 +22,6 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
@ -40,7 +39,15 @@ import (
|
||||||
// It will be removed before the release.
|
// It will be removed before the release.
|
||||||
// TODO(matloob): Remove enabled once we have more confidence on the
|
// TODO(matloob): Remove enabled once we have more confidence on the
|
||||||
// module index.
|
// 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
|
// 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
|
// 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)
|
data, _, err := cache.Default().GetMmap(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Couldn't read from modindex. Assume we couldn't read from
|
// 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)
|
data, err = indexModule(modroot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result{nil, err}
|
return result{nil, err}
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,6 @@ func (ts *testScript) setup() {
|
||||||
"GOCACHE=" + testGOCACHE,
|
"GOCACHE=" + testGOCACHE,
|
||||||
"GODEBUG=" + os.Getenv("GODEBUG"),
|
"GODEBUG=" + os.Getenv("GODEBUG"),
|
||||||
"GOEXE=" + cfg.ExeSuffix,
|
"GOEXE=" + cfg.ExeSuffix,
|
||||||
"GOINDEX=true",
|
|
||||||
"GOOS=" + runtime.GOOS,
|
"GOOS=" + runtime.GOOS,
|
||||||
"GOPATH=" + filepath.Join(ts.workdir, "gopath"),
|
"GOPATH=" + filepath.Join(ts.workdir, "gopath"),
|
||||||
"GOPROXY=" + proxyURL,
|
"GOPROXY=" + proxyURL,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue