github.com/shulhan/golangci-lint@v1.10.1/pkg/golinters/unconvert.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 unconvertAPI "github.com/golangci/unconvert" 9 ) 10 11 type Unconvert struct{} 12 13 func (Unconvert) Name() string { 14 return "unconvert" 15 } 16 17 func (Unconvert) Desc() string { 18 return "Remove unnecessary type conversions" 19 } 20 21 func (lint Unconvert) Run(ctx context.Context, lintCtx *linter.Context) ([]result.Issue, error) { 22 positions := unconvertAPI.Run(lintCtx.Program) 23 if len(positions) == 0 { 24 return nil, nil 25 } 26 27 res := make([]result.Issue, 0, len(positions)) 28 for _, pos := range positions { 29 res = append(res, result.Issue{ 30 Pos: pos, 31 Text: "unnecessary conversion", 32 FromLinter: lint.Name(), 33 }) 34 } 35 36 return res, nil 37 }