]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: reject missing source code in go get -d, same as go get -d -u
authorRuss Cox <rsc@golang.org>
Tue, 14 Jul 2015 06:17:39 +0000 (02:17 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 15 Jul 2015 04:29:10 +0000 (04:29 +0000)
Fixes #11090.

Change-Id: I1518df7a48346b175ec80079a07225901fdd51fb
Reviewed-on: https://go-review.googlesource.com/12177
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/go/get.go
src/cmd/go/go_test.go

index f4780e18aa1af4b928816bc12aaa7f303869a5b5..12fe77a38282c56add1612ab41fba82d743abdb8 100644 (file)
@@ -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
        }
 
index c8741ca2ff1ff168ffb0f5866ffa2aa2f0026120..98486c5294e46573bea62fe836a5fb8616424062 100644 (file)
@@ -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()