aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Ziak <0xe2.0x9a.0x9b@gmail.com>2014-05-27 23:58:03 -0400
committerRuss Cox <rsc@golang.org>2014-05-27 23:58:03 -0400
commiteeb87c3660932cb0dcc6db2e3784a66b6d06a82a (patch)
tree3b69c872eb93f6666d8fc78a5dbe5011433f320a
parent74ce581b06fc4f0de1c862604830ce312283a7db (diff)
downloadgo-eeb87c3660932cb0dcc6db2e3784a66b6d06a82a.tar.gz
go-eeb87c3660932cb0dcc6db2e3784a66b6d06a82a.zip
cmd/go: do not miss an error if import path contains "cmd/something"
Fixes #7638 LGTM=rsc R=rsc, adg, robert.hencke, bradfitz CC=golang-codereviews https://golang.org/cl/89280043
-rw-r--r--src/cmd/go/get.go4
-rw-r--r--src/cmd/go/pkg.go2
2 files changed, 6 insertions, 0 deletions
diff --git a/src/cmd/go/get.go b/src/cmd/go/get.go
index 94f8083477..e708fcf779 100644
--- a/src/cmd/go/get.go
+++ b/src/cmd/go/get.go
@@ -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 {
diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go
index 16a99f382d..d45df265b9 100644
--- a/src/cmd/go/pkg.go
+++ b/src/cmd/go/pkg.go
@@ -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