@@ -23,6 +23,7 @@ import (
23
23
"github.com/golangci/golangci-lint/pkg/lint/astcache"
24
24
"github.com/golangci/golangci-lint/pkg/lint/linter"
25
25
"github.com/golangci/golangci-lint/pkg/logutils"
26
+ libpackages "github.com/golangci/golangci-lint/pkg/packages"
26
27
)
27
28
28
29
type ContextLoader struct {
@@ -88,7 +89,7 @@ func shouldSkipPkg(pkg *packages.Package) bool {
88
89
func (cl ContextLoader ) makeFakeLoaderProgram (pkgs []* packages.Package ) * loader.Program {
89
90
var createdPkgs []* loader.PackageInfo
90
91
for _ , pkg := range pkgs {
91
- if len ( pkg .Errors ) != 0 {
92
+ if pkg .IllTyped {
92
93
// some linters crash on packages with errors,
93
94
// skip them and warn about them in another place
94
95
continue
@@ -104,7 +105,7 @@ func (cl ContextLoader) makeFakeLoaderProgram(pkgs []*packages.Package) *loader.
104
105
allPkgs [pkg .Pkg ] = pkg
105
106
}
106
107
for _ , pkg := range pkgs {
107
- if len ( pkg .Errors ) != 0 {
108
+ if pkg .IllTyped {
108
109
// some linters crash on packages with errors,
109
110
// skip them and warn about them in another place
110
111
continue
@@ -346,8 +347,8 @@ func (cl ContextLoader) Load(ctx context.Context, linters []linter.Config) (*lin
346
347
saveNotCompilingPackages (ret )
347
348
} else {
348
349
for _ , pkg := range pkgs {
349
- if len ( pkg .Errors ) != 0 {
350
- cl .log .Infof ("Pkg %s errors: %v" , pkg .ID , pkg . Errors )
350
+ if pkg .IllTyped {
351
+ cl .log .Infof ("Pkg %s errors: %v" , pkg .ID , libpackages . ExtractErrors ( pkg ) )
351
352
}
352
353
}
353
354
}
@@ -360,7 +361,7 @@ func (cl ContextLoader) Load(ctx context.Context, linters []linter.Config) (*lin
360
361
// which can work with them.
361
362
func saveNotCompilingPackages (lintCtx * linter.Context ) {
362
363
for _ , pkg := range lintCtx .Packages {
363
- if len ( pkg .Errors ) != 0 {
364
+ if pkg .IllTyped {
364
365
lintCtx .NotCompilingPackages = append (lintCtx .NotCompilingPackages , pkg )
365
366
}
366
367
}
0 commit comments