@@ -23,6 +23,7 @@ import (
2323 "github.com/golangci/golangci-lint/pkg/lint/astcache"
2424 "github.com/golangci/golangci-lint/pkg/lint/linter"
2525 "github.com/golangci/golangci-lint/pkg/logutils"
26+ libpackages "github.com/golangci/golangci-lint/pkg/packages"
2627)
2728
2829type ContextLoader struct {
@@ -88,7 +89,7 @@ func shouldSkipPkg(pkg *packages.Package) bool {
8889func (cl ContextLoader ) makeFakeLoaderProgram (pkgs []* packages.Package ) * loader.Program {
8990 var createdPkgs []* loader.PackageInfo
9091 for _ , pkg := range pkgs {
91- if len ( pkg .Errors ) != 0 {
92+ if pkg .IllTyped {
9293 // some linters crash on packages with errors,
9394 // skip them and warn about them in another place
9495 continue
@@ -104,7 +105,7 @@ func (cl ContextLoader) makeFakeLoaderProgram(pkgs []*packages.Package) *loader.
104105 allPkgs [pkg .Pkg ] = pkg
105106 }
106107 for _ , pkg := range pkgs {
107- if len ( pkg .Errors ) != 0 {
108+ if pkg .IllTyped {
108109 // some linters crash on packages with errors,
109110 // skip them and warn about them in another place
110111 continue
@@ -346,8 +347,8 @@ func (cl ContextLoader) Load(ctx context.Context, linters []linter.Config) (*lin
346347 saveNotCompilingPackages (ret )
347348 } else {
348349 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 ) )
351352 }
352353 }
353354 }
@@ -360,7 +361,7 @@ func (cl ContextLoader) Load(ctx context.Context, linters []linter.Config) (*lin
360361// which can work with them.
361362func saveNotCompilingPackages (lintCtx * linter.Context ) {
362363 for _ , pkg := range lintCtx .Packages {
363- if len ( pkg .Errors ) != 0 {
364+ if pkg .IllTyped {
364365 lintCtx .NotCompilingPackages = append (lintCtx .NotCompilingPackages , pkg )
365366 }
366367 }
0 commit comments