diff --git a/go/tools/builders/nogo_main.go b/go/tools/builders/nogo_main.go index 2830a666..ce0e6e39 100644 --- a/go/tools/builders/nogo_main.go +++ b/go/tools/builders/nogo_main.go @@ -386,13 +386,11 @@ func checkAnalysisResults(actions []*action, pkg *goPackage) string { } // Discard diagnostics based on the analyzer configuration. for _, d := range act.diagnostics { - // NOTE(golang.org/issue/31008): nilness does not set positions, - // so don't assume the position is valid. - f := pkg.fset.File(d.Pos) - filename := "-" - if f != nil { - filename = f.Name() + file := pkg.fset.File(d.Pos) + if file == nil { + continue } + filename := file.Name() include := true if len(config.onlyFiles) > 0 { // This analyzer emits diagnostics for only a set of files.