Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 733 Bytes

generation.md

File metadata and controls

32 lines (24 loc) · 733 Bytes

Generation


Fns的代码生成器。

使用

一般在internal/generator/包下。

main.go 中构建生成器。

func main() {
	g := generates.New()
	if err := g.Execute(context.Background(), os.Args...); err != nil {
		fmt.Println(fmt.Sprintf("%+v", err))
	}
}

调整

generates.New() 中可以添加选项来调整。

一般会用到WithAnnotations多一点,比如增加sql的注解支持。

选项 说明
WithName 设置bin的名字
WithModulesDir 设置mod的目录
WithAnnotations 添加新的注解支持
WithBuiltinTypes 添加新的内置类型
WithGenerator 添加额外的生成器