generator

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator 核心生成器

func New

func New(opt Options) (*Generator, error)

New 创建生成器实例

func (*Generator) Generate

func (g *Generator) Generate(services []*parser.Service) error

Generate is an alias for GenerateFull that accepts only a list of services. Models and Source are left at their zero values.

func (*Generator) GenerateFull added in v1.1.0

func (g *Generator) GenerateFull(result *parser.ParseResult) error

GenerateFull 执行完整生成流程

type Options

type Options struct {
	TemplateFS  fs.FS    // 模板文件系统
	OutputDir   string   // 输出目录
	ImportPath  string   // 项目导入路径
	ServiceName string   // 服务名称
	Protocols   []string // 支持的协议 (http, grpc)
	WithConfig  bool     // 是否生成配置文件
	WithDocs    bool     // 是否生成文档(README)
	WithTests   bool     // 是否生成测试文件
	WithModel   bool     // 是否生成 gorm model + repository
	WithGRPC    bool     // 是否生成 gRPC 传输层
	WithDB      bool     // main 是否包含数据库初始化代码
	DBDriver    string   // 数据库驱动
	WithSwag    bool     // 是否生成 swaggo 注释
	WithSkill   bool     // 是否生成 AI Skill (MCP server) 支持
	IDLSrcPath  string   // IDL 源文件路径
	RoutePrefix string   // HTTP 路由前缀
}

Options 生成器配置选项

type SvcRoute added in v1.2.0

type SvcRoute struct {
	Service    *parser.Service
	FullPrefix string
}

SvcRoute helper for main.tmpl

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL