33 lines
		
	
	
		
			846 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			846 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 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/golinters/goanalysis"
 | |
| )
 | |
| 
 | |
| func NewErrorLint(cfg *config.ErrorLintSettings) *goanalysis.Linter {
 | |
| 	a := errorlint.NewAnalyzer()
 | |
| 
 | |
| 	cfgMap := map[string]map[string]interface{}{}
 | |
| 
 | |
| 	if cfg != nil {
 | |
| 		cfgMap[a.Name] = map[string]interface{}{
 | |
| 			"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)
 | |
| }
 | 
![dependabot[bot]](/assets/img/avatar_default.png)