Commit db454afd authored by Sebastien Binet's avatar Sebastien Binet Committed by Rob Pike

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/6266Reviewed-by: default avatarRob Pike <r@golang.org>
parent fc9a234d
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment