]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: clear cmd cache to avoid duplicate loads errors
authorDmitriy Dudkin <dudkin.dmitriy@gmail.com>
Thu, 25 Feb 2016 19:48:57 +0000 (21:48 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 25 Feb 2016 21:31:39 +0000 (21:31 +0000)
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>
src/cmd/go/get.go
src/cmd/go/go_test.go

index a298049a9d21de2b498a3f6fa801fae8e1b4bf38..9d4b94acf18f338b4c25517a130ea6ccca5f0c05 100644 (file)
@@ -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)
 
index 1d6184c337816fa7904424f001895a8e4616c399..928224cee69a8a5a3985b141fe981fa44f33b0b9 100644 (file)
@@ -2789,3 +2789,15 @@ func TestCgoConsistentResults(t *testing.T) {
                t.Error("building cgotest twice did not produce the same output")
        }
 }
+
+// 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")
+}