]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: allow go get with local path
authorSebastien Binet <seb.binet@gmail.com>
Fri, 27 Feb 2015 23:41:31 +0000 (00:41 +0100)
committerRob Pike <r@golang.org>
Mon, 23 Mar 2015 22:14:17 +0000 (22:14 +0000)
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>
src/cmd/go/get.go
src/cmd/go/test.bash

index 01ca4b2acdf6cfef0040b25cb625884542c3dd3e..c7399ebfcc967c923686af75c38714af75d72a61 100644 (file)
@@ -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
index 25d3c66665f3e36ce162cebc9465f4a1d2870688..39071e976f3b2f0da39adc59db41a8cfdf713d2c 100755 (executable)
@@ -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