gomen

package
v4.3.7 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: Apache-2.0 Imports: 15 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 NewGenerator

func NewGenerator(options Options) (*Generator, error)

NewGenerator 创建代码生成器实例

func (*Generator) Close

func (g *Generator) Close() error

Close 关闭生成器

func (*Generator) Connect added in v4.1.4

func (g *Generator) Connect() error

Connect connects to the database

func (*Generator) Generate

func (g *Generator) Generate(writer io.Writer) error

Generate 生成代码

func (*Generator) GenerateModelRegistry added in v4.3.7

func (g *Generator) GenerateModelRegistry(tables []string, writer io.Writer) error

generateModelRegistry 生成模型注册文件

func (*Generator) GenerateTableStruct added in v4.3.7

func (g *Generator) GenerateTableStruct(tableName string, writer io.Writer) error

GenerateTableStruct 生成单个表的结构体

type Options

type Options struct {
	Driver      string // 数据库驱动类型 (mysql/postgres)
	URL         string // 数据库连接URL
	OutputDir   string // 输出目录
	PackageName string // 包名
	Pattern     string // 表名匹配模式 (PostgreSQL 可用 schema.table* 格式)
	Debug       bool   // 是否开启调试模式
	TagStyle    string // 标签风格 (gom/db)
	GenerateDB  bool   // 是否生成db标签
	Prefix      string // 表名前缀(生成时会去掉)
	Suffix      string // 表名后缀(生成时会去掉)
}

Options 代码生成选项

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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