1 Star 0 Fork 0

bughou / go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
size_rule.go 463 Bytes
一键复制 编辑 原始数据 按行查看 历史
bughou 提交于 2022-03-21 20:37 . save
package structpkg
import (
"fmt"
"go/ast"
"go/token"
"gitee.com/go-better/dev/tool/gospec/problems"
)
type sizeRule struct {
MaxFields uint `yaml:"maxFields"`
}
func (r sizeRule) check(strut *ast.StructType, key string, fileSet *token.FileSet) {
if num := strut.Fields.NumFields(); uint(num) > r.MaxFields {
problems.Add(fileSet.Position(strut.Pos()), fmt.Sprintf(
"struct size: %d fields, limit: %d", num, r.MaxFields,
), key+".maxFields")
}
}
Go
1
https://gitee.com/bughou/go.git
git@gitee.com:bughou/go.git
bughou
go
go
d31700df43a9

搜索帮助