Add GOOS and GOARCH to nogo findings.

PiperOrigin-RevId: 511689371
This commit is contained in:
Adin Scannell
2023-02-22 22:14:13 -08:00
committed by gVisor bot
parent 05d60444e0
commit 2f9fabe0ac
2 changed files with 12 additions and 1 deletions
+4
View File
@@ -453,6 +453,8 @@ func (i *importer) checkPackage(path string, srcs []string) (*types.Package, Fin
Category: a.Name,
Position: i.fset.Position(d.Pos),
Message: d.Message,
GOOS: flags.GOOS,
GOARCH: flags.GOARCH,
})
},
ImportPackageFact: func(pkg *types.Package, ptr analysis.Fact) bool {
@@ -609,6 +611,8 @@ func (i *importer) checkPackage(path string, srcs []string) (*types.Package, Fin
Category: a.Name,
Position: token.Position{Filename: filename},
Message: errs[a].Error(),
GOOS: flags.GOOS,
GOARCH: flags.GOARCH,
})
continue
}
+8 -1
View File
@@ -29,11 +29,18 @@ type Finding struct {
Category string
Position token.Position
Message string
GOARCH string
GOOS string
}
// String implements fmt.Stringer.String.
func (f *Finding) String() string {
return fmt.Sprintf("%s: %s: %s", f.Category, f.Position.String(), f.Message)
if f.GOARCH == "" && f.GOOS == "" {
// Use the legacy simplified string.
return fmt.Sprintf("%s: %s: %s", f.Category, f.Position.String(), f.Message)
}
// Use the more complete information.
return fmt.Sprintf("%s: %s: %s (GOOARCH=%s, GOOS=%s)", f.Category, f.Position.String(), f.Message, f.GOARCH, f.GOOS)
}
// FindingSet is a collection of findings.