forked from golangci/golangci-lint
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherrorlint.go
32 lines (26 loc) · 820 Bytes
/
errorlint.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package golinters
import (
"github.com/polyfloyd/go-errorlint/errorlint"
"golang.org/x/tools/go/analysis"
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/goanalysis"
)
func NewErrorLint(cfg *config.ErrorLintSettings) *goanalysis.Linter {
a := errorlint.NewAnalyzer()
cfgMap := map[string]map[string]any{}
if cfg != nil {
cfgMap[a.Name] = map[string]any{
"errorf": cfg.Errorf,
"errorf-multi": cfg.ErrorfMulti,
"asserts": cfg.Asserts,
"comparison": cfg.Comparison,
}
}
return goanalysis.NewLinter(
a.Name,
"errorlint is a linter for that can be used to find code "+
"that will cause problems with the error wrapping scheme introduced in Go 1.13.",
[]*analysis.Analyzer{a},
cfgMap,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}