@@ -196,20 +196,24 @@ func discoverGoRoot() (string, error) {
196
196
func separateNotCompilingPackages (lintCtx * golinters.Context ) {
197
197
prog := lintCtx .Program
198
198
199
- compilingCreated := make ([]* loader.PackageInfo , 0 , len (prog .Created ))
200
- for _ , info := range prog .Created {
201
- if len (info .Errors ) != 0 {
202
- lintCtx .NotCompilingPackages = append (lintCtx .NotCompilingPackages , info )
203
- } else {
204
- compilingCreated = append (compilingCreated , info )
199
+ if prog .Created != nil {
200
+ compilingCreated := make ([]* loader.PackageInfo , 0 , len (prog .Created ))
201
+ for _ , info := range prog .Created {
202
+ if len (info .Errors ) != 0 {
203
+ lintCtx .NotCompilingPackages = append (lintCtx .NotCompilingPackages , info )
204
+ } else {
205
+ compilingCreated = append (compilingCreated , info )
206
+ }
205
207
}
208
+ prog .Created = compilingCreated
206
209
}
207
- prog .Created = compilingCreated
208
210
209
- for k , info := range prog .Imported {
210
- if len (info .Errors ) != 0 {
211
- lintCtx .NotCompilingPackages = append (lintCtx .NotCompilingPackages , info )
212
- delete (prog .Imported , k )
211
+ if prog .Imported != nil {
212
+ for k , info := range prog .Imported {
213
+ if len (info .Errors ) != 0 {
214
+ lintCtx .NotCompilingPackages = append (lintCtx .NotCompilingPackages , info )
215
+ delete (prog .Imported , k )
216
+ }
213
217
}
214
218
}
215
219
}
@@ -261,7 +265,9 @@ func buildLintCtx(ctx context.Context, linters []pkg.Linter, cfg *config.Config)
261
265
ASTCache : astCache ,
262
266
}
263
267
264
- separateNotCompilingPackages (ret )
268
+ if prog != nil {
269
+ separateNotCompilingPackages (ret )
270
+ }
265
271
266
272
return ret , nil
267
273
}
0 commit comments