github.com/chenfeining/golangci-lint@v1.0.2-0.20230730162517-14c6c67868df/pkg/golinters/gochecknoglobals.go (about) 1 package golinters 2 3 import ( 4 "4d63.com/gochecknoglobals/checknoglobals" 5 "golang.org/x/tools/go/analysis" 6 7 "github.com/chenfeining/golangci-lint/pkg/golinters/goanalysis" 8 ) 9 10 func NewGochecknoglobals() *goanalysis.Linter { 11 gochecknoglobals := checknoglobals.Analyzer() 12 13 // gochecknoglobals only lints test files if the `-t` flag is passed, so we 14 // pass the `t` flag as true to the analyzer before running it. This can be 15 // turned off by using the regular golangci-lint flags such as `--tests` or 16 // `--skip-files`. 17 linterConfig := map[string]map[string]any{ 18 gochecknoglobals.Name: { 19 "t": true, 20 }, 21 } 22 23 return goanalysis.NewLinter( 24 gochecknoglobals.Name, 25 gochecknoglobals.Doc, 26 []*analysis.Analyzer{gochecknoglobals}, 27 linterConfig, 28 ).WithLoadMode(goanalysis.LoadModeTypesInfo) 29 }