Previously, running 'go get' with a local path would correctly
download the package but fail to install it.
This is because a sticky error - resulting from discovering that the
package needed to be downloaded - was still around.
Theoretically, such sticky errors would be cleared but they weren't
because the map tracking these errors were indexed with the correct
canonical import path of the package (e.g. "ex.com/x/pkg") whereas the
clearing was done with the local path (e.g. "./pkg".)
Always use the canonical import path.
Fixes #9767
Change-Id: Ia0e8a51ac591d4c833d11285da5b767ef7ed8ad2
Reviewed-on: https://go-review.googlesource.com/6266
Reviewed-by: Rob Pike <r@golang.org>
return
}
+ // loadPackage inferred the canonical ImportPath from arg.
+ // Use that in the following to prevent hysteresis effects
+ // in e.g. downloadCache and packageCache.
+ // This allows invocations such as:
+ // mkdir -p $GOPATH/src/github.com/user
+ // cd $GOPATH/src/github.com/user
+ // go get ./foo
+ // see: golang.org/issue/9767
+ arg = p.ImportPath
+
// There's nothing to do if this is a package in the standard library.
if p.Standard {
return
unset GOPATH
rm -rf $d
+TEST go get ./rsc.io/toolstash '(golang.org/issue/9767)'
+d=$(TMPDIR=/var/tmp mktemp -d -t testgoXXX)
+export GOPATH=$d
+export testgo=$(pwd)/testgo
+mkdir -p $GOPATH/src/rsc.io
+(cd $GOPATH/src/rsc.io && $testgo get ./toolstash) || ok=false
+unset GOPATH
+unset testgo
+rm -rf $d
+
# clean up
if $started; then stop; fi
rm -rf testdata/bin testdata/bin1