@@ -82,9 +82,11 @@ func newLinter(opts options) (*linter, error) {
82
82
}
83
83
84
84
type lintResult struct {
85
- checkedFiles []string
86
- diagnostics []diagnostic
87
- warnings []string
85
+ // These fields are exported so that we can gob encode them.
86
+
87
+ CheckedFiles []string
88
+ Diagnostics []diagnostic
89
+ Warnings []string
88
90
}
89
91
90
92
type options struct {
@@ -148,8 +150,8 @@ func (l *linter) run(bconf buildConfig) (lintResult, error) {
148
150
}()
149
151
}
150
152
res , err := l .lint (r , cfg , l .opts .patterns )
151
- for i := range res .diagnostics {
152
- res .diagnostics [i ].buildName = bconf .Name
153
+ for i := range res .Diagnostics {
154
+ res .Diagnostics [i ].buildName = bconf .Name
153
155
}
154
156
return res , err
155
157
}
@@ -185,18 +187,18 @@ func (l *linter) lint(r *runner.Runner, cfg *packages.Config, patterns []string)
185
187
panic ("package has errors but isn't marked as failed" )
186
188
}
187
189
if res .Failed {
188
- out .diagnostics = append (out .diagnostics , failed (res )... )
190
+ out .Diagnostics = append (out .Diagnostics , failed (res )... )
189
191
} else {
190
192
if res .Skipped {
191
- out .warnings = append (out .warnings , fmt .Sprintf ("skipped package %s because it is too large" , res .Package ))
193
+ out .Warnings = append (out .Warnings , fmt .Sprintf ("skipped package %s because it is too large" , res .Package ))
192
194
continue
193
195
}
194
196
195
197
if ! res .Initial {
196
198
continue
197
199
}
198
200
199
- out .checkedFiles = append (out .checkedFiles , res .Package .GoFiles ... )
201
+ out .CheckedFiles = append (out .CheckedFiles , res .Package .GoFiles ... )
200
202
allowedAnalyzers := filterAnalyzerNames (analyzerNames , res .Config .Checks )
201
203
resd , err := res .Load ()
202
204
if err != nil {
@@ -215,7 +217,7 @@ func (l *linter) lint(r *runner.Runner, cfg *packages.Config, patterns []string)
215
217
filtered [i ].mergeIf = a .Doc .MergeIf
216
218
}
217
219
}
218
- out .diagnostics = append (out .diagnostics , filtered ... )
220
+ out .Diagnostics = append (out .Diagnostics , filtered ... )
219
221
220
222
for _ , obj := range resd .Unused .Used {
221
223
// Note: a side-effect of this code is that fields in instantiated structs are handled correctly. Even
@@ -254,7 +256,7 @@ func (l *linter) lint(r *runner.Runner, cfg *packages.Config, patterns []string)
254
256
if used [uo .key ] {
255
257
continue
256
258
}
257
- out .diagnostics = append (out .diagnostics , diagnostic {
259
+ out .Diagnostics = append (out .Diagnostics , diagnostic {
258
260
Diagnostic : runner.Diagnostic {
259
261
Position : uo .obj .DisplayPosition ,
260
262
Message : fmt .Sprintf ("%s %s is unused" , uo .obj .Kind , uo .obj .Name ),
0 commit comments