diff --git a/src/cmd/go/get.go b/src/cmd/go/get.go index f4780e18aa1..12fe77a3828 100644 --- a/src/cmd/go/get.go +++ b/src/cmd/go/get.go @@ -96,12 +96,13 @@ func runGet(cmd *Command, args []string) { } args = importPaths(args) + packagesForBuild(args) // Phase 3. Install. if *getD { // Download only. // Check delayed until now so that importPaths - // has a chance to print errors. + // and packagesForBuild have a chance to print errors. return } diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index c8741ca2ff1..98486c5294e 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -1184,6 +1184,22 @@ func TestGodocInstalls(t *testing.T) { tg.wantExecutable(filepath.Join(goroot, "bin", "godoc"), "did not install godoc to $GOROOT/bin") } +func TestGoGetNonPkg(t *testing.T) { + testenv.MustHaveExternalNetwork(t) + + tg := testgo(t) + defer tg.cleanup() + tg.tempDir("gobin") + tg.setenv("GOPATH", tg.path(".")) + tg.setenv("GOBIN", tg.path("gobin")) + tg.runFail("get", "-d", "golang.org/x/tools") + tg.grepStderr("golang.org/x/tools: no buildable Go source files", "missing error") + tg.runFail("get", "-d", "-u", "golang.org/x/tools") + tg.grepStderr("golang.org/x/tools: no buildable Go source files", "missing error") + tg.runFail("get", "-d", "golang.org/x/tools") + tg.grepStderr("golang.org/x/tools: no buildable Go source files", "missing error") +} + func TestInstalls(t *testing.T) { tg := testgo(t) defer tg.cleanup()