Skip to content

Commit

Permalink
lintcmd: trim cache
Browse files Browse the repository at this point in the history
Closes gh-1283
  • Loading branch information
dominikh committed Jun 3, 2022
1 parent f27f124 commit ec2239c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lintcmd/cmd.go
Expand Up @@ -537,6 +537,7 @@ func (cmd *Command) exit(code int) {
os.Exit(code)
}

// printDiagnostics prints the diagnostics and exits the process.
func (cmd *Command) printDiagnostics(cs []*lint.Analyzer, diagnostics []diagnostic) {
if len(diagnostics) > 1 {
sort.Slice(diagnostics, func(i, j int) bool {
Expand Down
3 changes: 3 additions & 0 deletions lintcmd/lint.go
Expand Up @@ -31,6 +31,7 @@ import (
type linter struct {
analyzers map[string]*lint.Analyzer
runner *runner.Runner
cache *cache.Cache
}

func computeSalt() ([]byte, error) {
Expand Down Expand Up @@ -74,6 +75,7 @@ func newLinter(cfg config.Config) (*linter, error) {
r.FallbackGoVersion = defaultGoVersion()
return &linter{
runner: r,
cache: c,
}, nil
}

Expand Down Expand Up @@ -519,6 +521,7 @@ func doLint(as []*lint.Analyzer, paths []string, opt *options) (lintResult, erro
if err != nil {
return lintResult{}, err
}
defer l.cache.Trim()
analyzers := make(map[string]*lint.Analyzer, len(as))
for _, a := range as {
analyzers[a.Analyzer.Name] = a
Expand Down

0 comments on commit ec2239c

Please sign in to comment.