Skip to content

Commit

Permalink
cmd/go: allow go get with local path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
sbinet authored and robpike committed Mar 23, 2015
1 parent fc9a234 commit db454af
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cmd/go/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/cmd/go/test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit db454af

Please sign in to comment.