mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-08-28 22:28:43 -04:00
#40: fix panic in fast mode
This commit is contained in:
parent
0eb6aa7c59
commit
5646c61c73
3 changed files with 27 additions and 13 deletions
|
@ -196,20 +196,24 @@ func discoverGoRoot() (string, error) {
|
|||
func separateNotCompilingPackages(lintCtx *golinters.Context) {
|
||||
prog := lintCtx.Program
|
||||
|
||||
compilingCreated := make([]*loader.PackageInfo, 0, len(prog.Created))
|
||||
for _, info := range prog.Created {
|
||||
if len(info.Errors) != 0 {
|
||||
lintCtx.NotCompilingPackages = append(lintCtx.NotCompilingPackages, info)
|
||||
} else {
|
||||
compilingCreated = append(compilingCreated, info)
|
||||
if prog.Created != nil {
|
||||
compilingCreated := make([]*loader.PackageInfo, 0, len(prog.Created))
|
||||
for _, info := range prog.Created {
|
||||
if len(info.Errors) != 0 {
|
||||
lintCtx.NotCompilingPackages = append(lintCtx.NotCompilingPackages, info)
|
||||
} else {
|
||||
compilingCreated = append(compilingCreated, info)
|
||||
}
|
||||
}
|
||||
prog.Created = compilingCreated
|
||||
}
|
||||
prog.Created = compilingCreated
|
||||
|
||||
for k, info := range prog.Imported {
|
||||
if len(info.Errors) != 0 {
|
||||
lintCtx.NotCompilingPackages = append(lintCtx.NotCompilingPackages, info)
|
||||
delete(prog.Imported, k)
|
||||
if prog.Imported != nil {
|
||||
for k, info := range prog.Imported {
|
||||
if len(info.Errors) != 0 {
|
||||
lintCtx.NotCompilingPackages = append(lintCtx.NotCompilingPackages, info)
|
||||
delete(prog.Imported, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +265,9 @@ func buildLintCtx(ctx context.Context, linters []pkg.Linter, cfg *config.Config)
|
|||
ASTCache: astCache,
|
||||
}
|
||||
|
||||
separateNotCompilingPackages(ret)
|
||||
if prog != nil {
|
||||
separateNotCompilingPackages(ret)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue