Skip to content

Commit 286a9c3

Browse files
tmwhadg
authored andcommitted
cmd/go: clear cmd cache to avoid duplicate loads errors
go get -u all command updates all packages including standard commands. We need to get commands evicted from their cache to avoid loading old versions of the packages evicted from the packages cache. Fixes #14444 Change-Id: Icd581a26e1db34ca634aba595fed62b097094c2f Reviewed-on: https://go-review.googlesource.com/19899 Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-on: https://go-review.googlesource.com/22040 Reviewed-by: Andrew Gerrand <[email protected]>
1 parent 3778f79 commit 286a9c3

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/cmd/go/get.go

+8
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ func runGet(cmd *Command, args []string) {
119119
delete(packageCache, name)
120120
}
121121

122+
// In order to rebuild packages information completely,
123+
// we need to clear commands cache. Command packages are
124+
// referring to evicted packages from the package cache.
125+
// This leads to duplicated loads of the standard packages.
126+
for name := range cmdCache {
127+
delete(cmdCache, name)
128+
}
129+
122130
args = importPaths(args)
123131
packagesForBuild(args)
124132

src/cmd/go/go_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -2759,3 +2759,15 @@ func TestParallelTest(t *testing.T) {
27592759
tg.setenv("GOPATH", tg.path("."))
27602760
tg.run("test", "-p=4", "p1", "p2", "p3", "p4")
27612761
}
2762+
2763+
// Issue 14444: go get -u .../ duplicate loads errors
2764+
func TestGoGetUpdateAllDoesNotTryToLoadDuplicates(t *testing.T) {
2765+
testenv.MustHaveExternalNetwork(t)
2766+
2767+
tg := testgo(t)
2768+
defer tg.cleanup()
2769+
tg.makeTempdir()
2770+
tg.setenv("GOPATH", tg.path("."))
2771+
tg.run("get", "-u", ".../")
2772+
tg.grepStderrNot("duplicate loads of", "did not remove old packages from cache")
2773+
}

0 commit comments

Comments
 (0)