summaryrefslogtreecommitdiffhomepage
path: root/tools/nogo/nogo.go
diff options
context:
space:
mode:
Diffstat (limited to 'tools/nogo/nogo.go')
-rw-r--r--tools/nogo/nogo.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/tools/nogo/nogo.go b/tools/nogo/nogo.go
index 120fdcff5..e19e3c237 100644
--- a/tools/nogo/nogo.go
+++ b/tools/nogo/nogo.go
@@ -264,12 +264,17 @@ func checkStdlib(config *stdlibConfig, ac map[*analysis.Analyzer]matcher) ([]str
// Closure to check a single package.
allFindings := make([]string, 0)
stdlibFacts := make(map[string][]byte)
+ stdlibErrs := make(map[string]error)
var checkOne func(pkg string) error // Recursive.
checkOne = func(pkg string) error {
// Is this already done?
if _, ok := stdlibFacts[pkg]; ok {
return nil
}
+ // Did this fail previously?
+ if _, ok := stdlibErrs[pkg]; ok {
+ return nil
+ }
// Lookup the configuration.
config, ok := packages[pkg]
@@ -283,6 +288,7 @@ func checkStdlib(config *stdlibConfig, ac map[*analysis.Analyzer]matcher) ([]str
// If there's no binary for this package, it is likely
// not built with the distribution. That's fine, we can
// just skip analysis.
+ stdlibErrs[pkg] = err
return nil
}
@@ -299,6 +305,7 @@ func checkStdlib(config *stdlibConfig, ac map[*analysis.Analyzer]matcher) ([]str
if err != nil {
// If we can't analyze a package from the standard library,
// then we skip it. It will simply not have any findings.
+ stdlibErrs[pkg] = err
return nil
}
stdlibFacts[pkg] = factData
@@ -312,7 +319,9 @@ func checkStdlib(config *stdlibConfig, ac map[*analysis.Analyzer]matcher) ([]str
// to evaluate in the order provided here. We do ensure however, that
// all packages are evaluated.
for pkg := range packages {
- checkOne(pkg)
+ if err := checkOne(pkg); err != nil {
+ return nil, nil, err
+ }
}
// Sanity check.
@@ -326,6 +335,11 @@ func checkStdlib(config *stdlibConfig, ac map[*analysis.Analyzer]matcher) ([]str
return nil, nil, fmt.Errorf("error saving stdlib facts: %w", err)
}
+ // Write out all errors.
+ for pkg, err := range stdlibErrs {
+ log.Printf("WARNING: error while processing %v: %v", pkg, err)
+ }
+
// Return all findings.
return allFindings, factData, nil
}
@@ -522,15 +536,15 @@ func Main() {
findings, factData, err = checkPackage(c, analyzerConfig, nil)
// Do we need to do escape analysis?
if *escapesOutput != "" {
- escapes, _, err := checkPackage(c, escapesConfig, nil)
- if err != nil {
- log.Fatalf("error performing escape analysis: %v", err)
- }
f, err := os.OpenFile(*escapesOutput, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
log.Fatalf("unable to open output %q: %v", *escapesOutput, err)
}
defer f.Close()
+ escapes, _, err := checkPackage(c, escapesConfig, nil)
+ if err != nil {
+ log.Fatalf("error performing escape analysis: %v", err)
+ }
for _, escape := range escapes {
fmt.Fprintf(f, "%s\n", escape)
}