1 Star 0 Fork 0

bughou / go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
const.go 634 Bytes
一键复制 编辑 原始数据 按行查看 历史
bughou 提交于 2022-03-21 20:37 . save
package constpkg
import (
"go/ast"
"go/token"
namepkg "gitee.com/go-better/dev/tool/gospec/rules/name"
)
var Const = Rule{
thing: "const",
key: "const",
Rule: namepkg.Rule{
MaxLen: 40,
Style: "camelCase",
},
}
var LocalConst = Rule{
thing: "local const",
key: "localConst",
Rule: namepkg.Rule{
MaxLen: 30,
Style: "lowerCamelCase",
},
}
func Check(local bool, node ast.Node, fileSet *token.FileSet) {
switch value := node.(type) {
case *ast.ValueSpec:
if value.Names[0].Obj.Kind == ast.Con {
if local {
LocalConst.check(value, fileSet)
} else {
Const.check(value, fileSet)
}
}
}
}
Go
1
https://gitee.com/bughou/go.git
git@gitee.com:bughou/go.git
bughou
go
go
d31700df43a9

搜索帮助

53164aa7 5694891 3bd8fe86 5694891