]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: do not miss an error if import path contains "cmd/something"
authorJan Ziak <0xe2.0x9a.0x9b@gmail.com>
Wed, 28 May 2014 03:58:03 +0000 (23:58 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 28 May 2014 03:58:03 +0000 (23:58 -0400)
Fixes #7638

LGTM=rsc
R=rsc, adg, robert.hencke, bradfitz
CC=golang-codereviews
https://golang.org/cl/89280043

src/cmd/go/get.go
src/cmd/go/pkg.go

index 94f8083477835efa449bdccb977f017805992e26..e708fcf779fc2591a37ffbe5437b5b0989d97ce9 100644 (file)
@@ -140,6 +140,10 @@ var downloadRootCache = map[string]bool{}
 // for the package named by the argument.
 func download(arg string, stk *importStack, getTestDeps bool) {
        p := loadPackage(arg, stk)
+       if p.Error != nil && p.Error.hard {
+               errorf("%s", p.Error)
+               return
+       }
 
        // There's nothing to do if this is a package in the standard library.
        if p.Standard {
index 16a99f382d0d18ed92ff96d6720a3a8d377862bf..d45df265b96ed3371ba8db6f6fa03aef8ee731ef 100644 (file)
@@ -139,6 +139,7 @@ type PackageError struct {
        Pos           string   // position of error
        Err           string   // the error itself
        isImportCycle bool     // the error is an import cycle
+       hard          bool     // whether the error is soft or hard; soft errors are ignored in some places
 }
 
 func (p *PackageError) Error() string {
@@ -715,6 +716,7 @@ func loadPackage(arg string, stk *importStack) *Package {
                                Error: &PackageError{
                                        ImportStack: stk.copy(),
                                        Err:         fmt.Sprintf("invalid import path: cmd/... is reserved for Go commands"),
+                                       hard:        true,
                                },
                        }
                        return p