github.com/trigonella/golangci-lint@v1.10.1/pkg/golinters/unparam.go (about) 1 package golinters 2 3 import ( 4 "context" 5 6 "github.com/golangci/golangci-lint/pkg/lint/linter" 7 "github.com/golangci/golangci-lint/pkg/result" 8 "mvdan.cc/unparam/check" 9 ) 10 11 type Unparam struct{} 12 13 func (Unparam) Name() string { 14 return "unparam" 15 } 16 17 func (Unparam) Desc() string { 18 return "Reports unused function parameters" 19 } 20 21 func (lint Unparam) Run(ctx context.Context, lintCtx *linter.Context) ([]result.Issue, error) { 22 us := &lintCtx.Settings().Unparam 23 24 c := &check.Checker{} 25 c.CallgraphAlgorithm(us.Algo) 26 c.CheckExportedFuncs(us.CheckExported) 27 c.Program(lintCtx.Program) 28 c.ProgramSSA(lintCtx.SSAProgram) 29 30 unparamIssues, err := c.Check() 31 if err != nil { 32 return nil, err 33 } 34 35 var res []result.Issue 36 for _, i := range unparamIssues { 37 res = append(res, result.Issue{ 38 Pos: lintCtx.Program.Fset.Position(i.Pos()), 39 Text: markIdentifiers(i.Message()), 40 FromLinter: lint.Name(), 41 }) 42 } 43 44 return res, nil 45 }