Ai
1 Star 0 Fork 0

Laomo./golangci-lint

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
structcheck.go 895 Bytes
一键复制 编辑 原始数据 按行查看 历史
golangci 提交于 2018-06-02 16:36 +08:00 . generate parts of README automatically
package golinters // nolint:dupl
import (
"context"
"fmt"
structcheckAPI "github.com/golangci/check/cmd/structcheck"
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/result"
)
type Structcheck struct{}
func (Structcheck) Name() string {
return "structcheck"
}
func (Structcheck) Desc() string {
return "Finds an unused struct fields"
}
func (s Structcheck) Run(ctx context.Context, lintCtx *linter.Context) ([]result.Issue, error) {
issues := structcheckAPI.Run(lintCtx.Program, lintCtx.Settings().Structcheck.CheckExportedFields)
if len(issues) == 0 {
return nil, nil
}
res := make([]result.Issue, 0, len(issues))
for _, i := range issues {
res = append(res, result.Issue{
Pos: i.Pos,
Text: fmt.Sprintf("%s is unused", formatCode(i.FieldName, lintCtx.Cfg)),
FromLinter: s.Name(),
})
}
return res, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LaomoBK/golangci-lint.git
git@gitee.com:LaomoBK/golangci-lint.git
LaomoBK
golangci-lint
golangci-lint
v1.10.1

搜索帮助