Commit 226b28c8 authored by Russ Cox's avatar Russ Cox

cmd/go: fix go get x/... matching internal directories

Fixes #11960.

Change-Id: I9361a9f17f4eaf8e4f54b4ba380fd50a4b9cf003
Reviewed-on: https://go-review.googlesource.com/13023Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 45971c60
......@@ -208,9 +208,6 @@ func download(arg string, parent *Package, stk *importStack, mode int) {
wildcardOkay := len(*stk) == 0
isWildcard := false
// Note: Do not stk.push(arg) and defer stk.pop() here.
// The push/pop below are using updated values of arg in some cases.
// Download if the package is missing, or update if we're using -u.
if p.Dir == "" || *getU {
// The actual download.
......@@ -258,9 +255,10 @@ func download(arg string, parent *Package, stk *importStack, mode int) {
pkgs = pkgs[:0]
for _, arg := range args {
stk.push(arg)
// Note: load calls loadPackage or loadImport,
// which push arg onto stk already.
// Do not push here too, or else stk will say arg imports arg.
p := load(arg, mode)
stk.pop()
if p.Error != nil {
errorf("%s", p.Error)
continue
......
......@@ -1961,7 +1961,7 @@ func TestGoGenerateRunFlag(t *testing.T) {
tg.grepStdoutNot("no", "go generate -run yes ./testdata/generate/test4.go selected no")
}
func TestGoGetWorksWithVanityWildcards(t *testing.T) {
func TestGoGetCustomDomainWildcard(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
tg := testgo(t)
......@@ -1972,6 +1972,17 @@ func TestGoGetWorksWithVanityWildcards(t *testing.T) {
tg.wantExecutable(tg.path("bin/pdfpasswd"+exeSuffix), "did not build rsc/io/pdf/pdfpasswd")
}
func TestGoGetInternalWildcard(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
tg := testgo(t)
defer tg.cleanup()
tg.makeTempdir()
tg.setenv("GOPATH", tg.path("."))
// used to fail with errors about internal packages
tg.run("get", "github.com/rsc/go-get-issue-11960/...")
}
func TestGoVetWithExternalTests(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
......
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