1
0
mirror of https://github.com/golang/go synced 2024-11-19 15:54:46 -07:00

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
This commit is contained in:
Jan Ziak 2014-05-27 23:58:03 -04:00 committed by Russ Cox
parent 74ce581b06
commit eeb87c3660
2 changed files with 6 additions and 0 deletions

View 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 {

View 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