diff --git a/pkg/linter/linter.go b/pkg/linter/linter.go index 5397bc3a..b8a46122 100644 --- a/pkg/linter/linter.go +++ b/pkg/linter/linter.go @@ -242,11 +242,6 @@ func (l Linter) lintWithRegoRules(ctx context.Context, input rules.Input) (repor errCh := make(chan error) doneCh := make(chan bool) - go func() { - wg.Wait() - doneCh <- true - }() - for _, name := range input.FileNames { wg.Add(1) @@ -280,6 +275,11 @@ func (l Linter) lintWithRegoRules(ctx context.Context, input rules.Input) (repor }(name) } + go func() { + wg.Wait() + doneCh <- true + }() + select { case <-ctx.Done(): return report.Report{}, fmt.Errorf("context cancelled: %w", ctx.Err())