aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Dudkin <dudkin.dmitriy@gmail.com>2016-02-25 21:48:57 +0200
committerAndrew Gerrand <adg@golang.org>2016-04-14 05:35:15 +0000
commit286a9c3d74aaec172195a034c2fbc6984ff67009 (patch)
tree8dc28f879c61c86df3aa243f1c52e7721708ac80
parent3778f798c66834f116a75d0be4dd6b6c4a2f52ae (diff)
downloadgo-286a9c3d74aaec172195a034c2fbc6984ff67009.tar.gz
go-286a9c3d74aaec172195a034c2fbc6984ff67009.zip
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 <bradfitz@golang.org> Reviewed-on: https://go-review.googlesource.com/22040 Reviewed-by: Andrew Gerrand <adg@golang.org>
-rw-r--r--src/cmd/go/get.go8
-rw-r--r--src/cmd/go/go_test.go12
2 files changed, 20 insertions, 0 deletions
diff --git a/src/cmd/go/get.go b/src/cmd/go/get.go
index a298049a9d..9d4b94acf1 100644
--- a/src/cmd/go/get.go
+++ b/src/cmd/go/get.go
@@ -119,6 +119,14 @@ func runGet(cmd *Command, args []string) {
delete(packageCache, name)
}
+ // In order to rebuild packages information completely,
+ // we need to clear commands cache. Command packages are
+ // referring to evicted packages from the package cache.
+ // This leads to duplicated loads of the standard packages.
+ for name := range cmdCache {
+ delete(cmdCache, name)
+ }
+
args = importPaths(args)
packagesForBuild(args)
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index 39e0f3e56d..acf4a39fad 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -2759,3 +2759,15 @@ func TestParallelTest(t *testing.T) {
tg.setenv("GOPATH", tg.path("."))
tg.run("test", "-p=4", "p1", "p2", "p3", "p4")
}
+
+// Issue 14444: go get -u .../ duplicate loads errors
+func TestGoGetUpdateAllDoesNotTryToLoadDuplicates(t *testing.T) {
+ testenv.MustHaveExternalNetwork(t)
+
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.makeTempdir()
+ tg.setenv("GOPATH", tg.path("."))
+ tg.run("get", "-u", ".../")
+ tg.grepStderrNot("duplicate loads of", "did not remove old packages from cache")
+}