This repository was archived by the owner on Jun 2, 2023. It is now read-only.
File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -9,16 +9,17 @@ import (
9
9
"io"
10
10
"os"
11
11
"path/filepath"
12
+ "runtime/debug"
12
13
"sort"
13
14
"strings"
14
15
"sync"
15
16
"time"
16
17
"unicode"
17
18
18
- "golang.org/x/tools/go/packages"
19
19
"github.com/golangci/go-tools/config"
20
20
"github.com/golangci/go-tools/ssa"
21
21
"github.com/golangci/go-tools/ssa/ssautil"
22
+ "golang.org/x/tools/go/packages"
22
23
)
23
24
24
25
type Job struct {
@@ -29,6 +30,7 @@ type Job struct {
29
30
problems []Problem
30
31
31
32
duration time.Duration
33
+ panicErr error
32
34
}
33
35
34
36
type Ignore interface {
@@ -451,6 +453,11 @@ func (l *Linter) Lint(initial []*packages.Package, stats *PerfStats) []Problem {
451
453
for _ , j := range jobs {
452
454
wg .Add (1 )
453
455
go func (j * Job ) {
456
+ defer func () {
457
+ if panicErr := recover (); panicErr != nil {
458
+ j .panicErr = fmt .Errorf ("panic: %s: %s" , panicErr , string (debug .Stack ()))
459
+ }
460
+ }()
454
461
defer wg .Done ()
455
462
sem <- struct {}{}
456
463
defer func () { <- sem }()
@@ -466,6 +473,10 @@ func (l *Linter) Lint(initial []*packages.Package, stats *PerfStats) []Problem {
466
473
wg .Wait ()
467
474
468
475
for _ , j := range jobs {
476
+ if j .panicErr != nil {
477
+ panic (j .panicErr )
478
+ }
479
+
469
480
if stats != nil {
470
481
stats .Jobs = append (stats .Jobs , JobStat {j .check .ID , j .duration })
471
482
}
You can’t perform that action at this time.
0 commit comments