From: Sebastien Binet Date: Fri, 27 Feb 2015 23:41:31 +0000 (+0100) Subject: cmd/go: allow go get with local path X-Git-Tag: go1.5beta1~1466 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=db454afd2353364ad1c3bcd6002def81871ed2b2;p=gostls13.git cmd/go: allow go get with local path 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 --- diff --git a/src/cmd/go/get.go b/src/cmd/go/get.go index 01ca4b2acd..c7399ebfcc 100644 --- a/src/cmd/go/get.go +++ b/src/cmd/go/get.go @@ -155,6 +155,16 @@ func download(arg string, stk *importStack, getTestDeps bool) { 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 diff --git a/src/cmd/go/test.bash b/src/cmd/go/test.bash index 25d3c66665..39071e976f 100755 --- a/src/cmd/go/test.bash +++ b/src/cmd/go/test.bash @@ -1120,6 +1120,16 @@ fi 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