mirror of
https://github.com/golang/go
synced 2024-11-18 19:24:39 -07:00
cmd/go: log compilation errors when scanning directories and packages
Before, some packages disappear silently if the package cannot be imported, such as if the import statement is unparseable. Before: % ls src foo issue % go list ./... _/home/r/bug/src/foo % After: % go list ./... src/issue/issue.go:3:5: expected 'STRING', found newline _/home/r/bug/src/foo % R=rsc CC=golang-dev https://golang.org/cl/10568043
This commit is contained in:
parent
1579020476
commit
53a00e2812
@ -486,6 +486,9 @@ func matchPackages(pattern string) []string {
|
|||||||
}
|
}
|
||||||
_, err = buildContext.ImportDir(path, 0)
|
_, err = buildContext.ImportDir(path, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if _, noGo := err.(*build.NoGoError); !noGo {
|
||||||
|
log.Print(err)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
pkgs = append(pkgs, name)
|
pkgs = append(pkgs, name)
|
||||||
@ -520,8 +523,10 @@ func matchPackages(pattern string) []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
_, err = buildContext.ImportDir(path, 0)
|
_, err = buildContext.ImportDir(path, 0)
|
||||||
if err != nil && strings.Contains(err.Error(), "no Go source files") {
|
if err != nil {
|
||||||
return nil
|
if _, noGo := err.(*build.NoGoError); noGo {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pkgs = append(pkgs, name)
|
pkgs = append(pkgs, name)
|
||||||
return nil
|
return nil
|
||||||
@ -588,6 +593,9 @@ func matchPackagesInFS(pattern string) []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if _, err = build.ImportDir(path, 0); err != nil {
|
if _, err = build.ImportDir(path, 0); err != nil {
|
||||||
|
if _, noGo := err.(*build.NoGoError); !noGo {
|
||||||
|
log.Print(err)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
pkgs = append(pkgs, name)
|
pkgs = append(pkgs, name)
|
||||||
|
Loading…
Reference in New Issue
Block a user