Documentation ¶
Index ¶
- Constants
- func SetExtraImport(i string)
- type Generator
- func (g *Generator) GenerateHeader()
- func (g *Generator) GenerateImports()
- func (g *Generator) GenerateImportsFlag()
- func (g *Generator) GeneratePkg()
- func (g *Generator) GenerateStructuresValid() (err error)
- func (g *Generator) GetPrintBuf() bytes.Buffer
- func (g *Generator) Run() error
- func (g *Generator) SetBuildTags(buildTags string)
- func (g *Generator) SetNote(note string)
- func (g *Generator) SetValidFuncExport(e bool)
- type NodeVisitor
- type Parser
- type StructInfo
- type Structure
Constants ¶
View Source
const ( //Version 版本号 Version = "v0.0.2" //PackageName 包名 PackageName = "easyvalid" )
View Source
const (
//ValidFlag 匹配标识
ValidFlag = "evalid"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator 文件生成器
func NewGenerator ¶
func NewGenerator(pkg *packages.Package, structs []*Structure, imports []*packages.Package) *Generator
NewGenerator 获取一个生成器
func (*Generator) GenerateImportsFlag ¶
func (g *Generator) GenerateImportsFlag()
GenerateImportsFlag 打印import
func (*Generator) GenerateStructuresValid ¶
GenerateStructuresValid 生成结构体的验证内容
func (*Generator) SetBuildTags ¶
SetBuildTags 外部设置构建标签
func (*Generator) SetValidFuncExport ¶
SetValidFuncExport 设置是否需要方法名导出
type NodeVisitor ¶
type NodeVisitor struct {
// contains filtered or unexported fields
}
NodeVisitor 节点遍历器
func (*NodeVisitor) DeclaredStructures ¶
func (nv *NodeVisitor) DeclaredStructures() []StructInfo
DeclaredStructures 返回已经声明的结构体
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser 项目解析器
func (*Parser) GetImports ¶
GetImports 获取类中的package引用
func (*Parser) GetStructure ¶
GetStructure 根据需要的结构体名称 获取已经解析的结构体
func (*Parser) GetStructures ¶
GetStructures 获取已经声明的结构体
type StructInfo ¶
StructInfo 简单的结构体信息
Click to show internal directories.
Click to hide internal directories.