aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2023-06-16 16:30:52 -0400
committerGopher Robot <gobot@golang.org>2023-08-14 22:05:13 +0000
commit1a91bb94b07a4583df61179faf009b1120eaf93e (patch)
tree8479ab5238c2763738afd1da5222c97297bbe4ca
parentede3e278ae8df8ce1beec4b251dbaa68b8d2ad48 (diff)
downloadgo-1a91bb94b07a4583df61179faf009b1120eaf93e.tar.gz
go-1a91bb94b07a4583df61179faf009b1120eaf93e.zip
[release-branch.go1.20] cmd/go: do not index std as a module in modcache
We do not index std as a whole module ever. When working in the main Go repo, files in package change often, so we don't want to pay the cost of reindexing all of std when what we really need is just to reindex strings. Per-package indexing works better for that case. When using a released Go toolchain, we don't have to worry about the whole module changing, but if we switch to whole-module indexing at that point, we have the potential for bugs that only happen in released toolchains. Probably not worth the risk. For similar reasons, we don't index the current work module as a whole module (individual packages are changing), so we use the heuristic that we only do whole-module indexing in the module cache. The new toolchain modules live in the module cache, though, and our heuristic was causing whole-module indexing for them. As predicted, enabling whole-module indexing for std when it's completely untested does in fact lead to bugs (a very minor one). This CL turns off whole-module indexing for std even when it is in the module cache, to bring toolchain module behavior back in line with the other ways to run toolchains. Updates #57001. For #61873. Change-Id: I5012dc713f566846eb4b2848facc7f75bc956eb9 Reviewed-on: https://go-review.googlesource.com/c/go/+/504119 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> (cherry picked from commit a7b179370124c0114036b98a14f3f17cf76c122d) Reviewed-on: https://go-review.googlesource.com/c/go/+/518415 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
-rw-r--r--src/cmd/go/internal/modindex/read.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/go/internal/modindex/read.go b/src/cmd/go/internal/modindex/read.go
index 7c4fa7a6ee..8f40fc46d4 100644
--- a/src/cmd/go/internal/modindex/read.go
+++ b/src/cmd/go/internal/modindex/read.go
@@ -162,7 +162,7 @@ func GetModule(modroot string) (*Module, error) {
return nil, errNotFromModuleCache
}
modroot = filepath.Clean(modroot)
- if !str.HasFilePathPrefix(modroot, cfg.GOMODCACHE) {
+ if str.HasFilePathPrefix(modroot, cfg.GOROOTsrc) || !str.HasFilePathPrefix(modroot, cfg.GOMODCACHE) {
return nil, errNotFromModuleCache
}
return openIndexModule(modroot, true)