gormmom

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 26 Imported by: 1

README

GitHub Workflow Status (branch) GoDoc Coverage Status Supported Go Versions GitHub Release Go Report Card

🌍 GORMMOM - Native Language Programming Revolution with GORM

gormmom is the native language programming engine that breaks down language barriers in database development. As the smart tag generation engine of the GORM ecosystem, it empowers teams worldwide to write database models in native languages while auto generating database-compatible GORM tags and column names.

🎯 Language Liberation: Code in Chinese, Arabic, Japanese, and various languages - gormmom bridges the gap between human expression and database requirements.


Ecosystem

GORM Type-Safe Ecosystem


CHINESE README

中文说明


🚀 Installation

go get github.com/yylego/gormmom

🔄 Tech Comparison

Ecosystem Java MyBatis Plus Python SQLAlchemy Go GORM Ecosystem
Type-Safe Columns Example::getName Example.name cls.Name.Eq()
Code Generation ✅ Plugin support ✅ Reflection ✅ AST precision
Repo Pattern ✅ BaseMapper ✅ Session API ✅ GormRepo
Native Language 🟡 Limited 🟡 Limited ✅ Complete support

🌟 The Problem & Solution

⚡ Standard Approach
// ❌ Common approach: Developers constrained to English naming
type Account struct {
    ID       uint   `gorm:"primaryKey"`
    Username string `gorm:"column:username;uniqueIndex"`
    Nickname string `gorm:"column:nickname;index"`
    Age      int    `gorm:"column:age"`
    PhoneNum string `gorm:"column:phone_num"`
    Mailbox  string `gorm:"column:mailbox"`
    Address  string `gorm:"column:address"`
    Status   string `gorm:"column:status;index"`
}
✅ GORMMOM Solution
// ✅ GORMMOM: Program in native language!
type T账户信息 struct {
    ID   uint   `gorm:"primaryKey"`
    Z账号 string `gorm:"uniqueIndex"`
    N昵称 string `gorm:"index"`
    A年龄 int    `gorm:""`
    D电话 string `gorm:""`
    E邮箱 string `gorm:""`
    J住址 string `gorm:""`
    S状态 string `gorm:"index"`
}

func (*T账户信息) TableName() string {
    return "accounts" // Database-compatible table name
}

🌍 Multi-Language Examples

繁體中文
type T賬戶信息 struct {
    ID    uint   `gorm:"primaryKey"`
    Z賬號  string `gorm:"uniqueIndex"`
    N暱稱  string `gorm:"index"`
    A年齡  int    `gorm:""`
    D電話  string `gorm:""`
    E郵箱  string `gorm:""`
    J住址  string `gorm:""`
    S狀態  string `gorm:"index"`
}

func (*T賬戶信息) TableName() string {
    return "accounts"
}
日本語
type Tアカウント情報 struct {
    ID        uint   `gorm:"primaryKey"`
    Aアカウント string `gorm:"uniqueIndex"`
    Nニックネーム string `gorm:"index"`
    N年齢      int    `gorm:""`
    D電話番号   string `gorm:""`
    Eメール    string `gorm:""`
    J住所      string `gorm:""`
    Sステータス  string `gorm:"index"`
}

func (*Tアカウント情報) TableName() string {
    return "accounts"
}
한국어
type T계정정보 struct {
    ID    uint   `gorm:"primaryKey"`
    G계정   string `gorm:"uniqueIndex"`
    N닉네임  string `gorm:"index"`
    N나이   int    `gorm:""`
    J전화번호 string `gorm:""`
    E이메일  string `gorm:""`
    J주소   string `gorm:""`
    S상태   string `gorm:"index"`
}

func (*T계정정보) TableName() string {
    return "accounts"
}

🛠️ Usage

1. Auto Tag Generation

Once gormmom executes, the struct gets database-compatible column tags:

// Generated with database-compatible column names
type T账户信息 struct {
    ID    uint   `gorm:"primaryKey"`
    Z账号  string `gorm:"column:z_zhang_hao;uniqueIndex"`
    N昵称  string `gorm:"column:n_ni_cheng;index"`
    A年龄  int    `gorm:"column:a_nian_ling"`
    D电话  string `gorm:"column:d_dian_hua"`
    E邮箱  string `gorm:"column:e_you_xiang"`
    J住址  string `gorm:"column:j_zhu_zhi"`
    S状态  string `gorm:"column:s_zhuang_tai;index"`
}
2. Generate Commands
# Step 1: Generate GORM tags with native language fields
go test -v -run TestGen/GenGormMom

# Step 2: Generate type-safe column methods (with gormcngen)
go test -v -run TestGen/GenGormCnm
3. Use with gormrepo

English Version:

// Create repo
repo := gormrepo.NewGormRepo(&Account{}, (&Account{}).Columns())

// Select - First (by username)
account, err := repo.With(ctx, db).First(func(db *gorm.DB, cls *AccountColumns) *gorm.DB {
    return db.Where(cls.Username.Eq("alice"))
})

// Select - First (by nickname)
account, err := repo.With(ctx, db).First(func(db *gorm.DB, cls *AccountColumns) *gorm.DB {
    return db.Where(cls.Nickname.Eq("Alice"))
})

// Select - Find
accounts, err := repo.With(ctx, db).Find(func(db *gorm.DB, cls *AccountColumns) *gorm.DB {
    return db.Where(cls.Age.Gte(18))
})

// Select - FindPage
accounts, err := repo.With(ctx, db).FindPage(
    func(db *gorm.DB, cls *AccountColumns) *gorm.DB {
        return db.Where(cls.Age.Gte(18))
    },
    func(cls *AccountColumns) gormcnm.OrderByBottle {
        return cls.ID.OrderByBottle("DESC")
    },
    &gormrepo.Pagination{Limit: 10, Offset: 0},
)

// Create
err := repo.With(ctx, db).Create(&Account{Username: "bob", Nickname: "Bob", Age: 25})

// Update
err := repo.With(ctx, db).Updates(
    func(db *gorm.DB, cls *AccountColumns) *gorm.DB {
        return db.Where(cls.ID.Eq(1))
    },
    func(cls *AccountColumns) map[string]interface{} {
        return cls.Kw(cls.Age.Kv(26)).AsMap()
    },
)

// Delete
err := repo.With(ctx, db).DeleteW(func(db *gorm.DB, cls *AccountColumns) *gorm.DB {
    return db.Where(cls.ID.Eq(1))
})

中文(简体)版本:

// Create repo
repo := gormrepo.NewGormRepo(&T账户信息{}, (&T账户信息{}).Columns())

// Select - First (by username)
account, err := repo.With(ctx, db).First(func(db *gorm.DB, cls *T账户信息Columns) *gorm.DB {
    return db.Where(cls.Z账号.Eq("wang-xiao-ming"))
})

// Select - First (by nickname)
account, err := repo.With(ctx, db).First(func(db *gorm.DB, cls *T账户信息Columns) *gorm.DB {
    return db.Where(cls.N昵称.Eq("王小明"))
})

// Select - Find
accounts, err := repo.With(ctx, db).Find(func(db *gorm.DB, cls *T账户信息Columns) *gorm.DB {
    return db.Where(cls.A年龄.Gte(18))
})

// Select - FindPage
accounts, err := repo.With(ctx, db).FindPage(
    func(db *gorm.DB, cls *T账户信息Columns) *gorm.DB {
        return db.Where(cls.A年龄.Gte(18))
    },
    func(cls *T账户信息Columns) gormcnm.OrderByBottle {
        return cls.ID.OrderByBottle("DESC")
    },
    &gormrepo.Pagination{Limit: 10, Offset: 0},
)

// Create
err := repo.With(ctx, db).Create(&T账户信息{Z账号: "han-mei-mei", N昵称: "韩梅梅", A年龄: 25})

// Update
err := repo.With(ctx, db).Updates(
    func(db *gorm.DB, cls *T账户信息Columns) *gorm.DB {
        return db.Where(cls.ID.Eq(1))
    },
    func(cls *T账户信息Columns) map[string]interface{} {
        return cls.Kw(cls.A年龄.Kv(26)).AsMap()
    },
)

// Delete
err := repo.With(ctx, db).DeleteW(func(db *gorm.DB, cls *T账户信息Columns) *gorm.DB {
    return db.Where(cls.ID.Eq(1))
})

中文(繁體)版本:

// Create repo
repo := gormrepo.NewGormRepo(&T賬戶信息{}, (&T賬戶信息{}).Columns())

// Select - First (by username)
account, err := repo.With(ctx, db).First(func(db *gorm.DB, cls *T賬戶信息Columns) *gorm.DB {
    return db.Where(cls.Z賬號.Eq("wang-xiao-ming"))
})

// Select - First (by nickname)
account, err := repo.With(ctx, db).First(func(db *gorm.DB, cls *T賬戶信息Columns) *gorm.DB {
    return db.Where(cls.N暱稱.Eq("王小明"))
})

// Select - Find
accounts, err := repo.With(ctx, db).Find(func(db *gorm.DB, cls *T賬戶信息Columns) *gorm.DB {
    return db.Where(cls.A年齡.Gte(18))
})

// Select - FindPage
accounts, err := repo.With(ctx, db).FindPage(
    func(db *gorm.DB, cls *T賬戶信息Columns) *gorm.DB {
        return db.Where(cls.A年齡.Gte(18))
    },
    func(cls *T賬戶信息Columns) gormcnm.OrderByBottle {
        return cls.ID.OrderByBottle("DESC")
    },
    &gormrepo.Pagination{Limit: 10, Offset: 0},
)

// Create
err := repo.With(ctx, db).Create(&T賬戶信息{Z賬號: "han-mei-mei", N暱稱: "韓梅梅", A年齡: 25})

// Update
err := repo.With(ctx, db).Updates(
    func(db *gorm.DB, cls *T賬戶信息Columns) *gorm.DB {
        return db.Where(cls.ID.Eq(1))
    },
    func(cls *T賬戶信息Columns) map[string]interface{} {
        return cls.Kw(cls.A年齡.Kv(26)).AsMap()
    },
)

// Delete
err := repo.With(ctx, db).DeleteW(func(db *gorm.DB, cls *T賬戶信息Columns) *gorm.DB {
    return db.Where(cls.ID.Eq(1))
})

日本語版:

// Create repo
repo := gormrepo.NewGormRepo(&Tアカウント情報{}, (&Tアカウント情報{}).Columns())

// Select - First (by username)
account, err := repo.With(ctx, db).First(func(db *gorm.DB, cls *Tアカウント情報Columns) *gorm.DB {
    return db.Where(cls.Aアカウント.Eq("tanaka"))
})

// Select - First (by nickname)
account, err := repo.With(ctx, db).First(func(db *gorm.DB, cls *Tアカウント情報Columns) *gorm.DB {
    return db.Where(cls.Nニックネーム.Eq("田中太郎"))
})

// Select - Find
accounts, err := repo.With(ctx, db).Find(func(db *gorm.DB, cls *Tアカウント情報Columns) *gorm.DB {
    return db.Where(cls.N年齢.Gte(18))
})

// Select - FindPage
accounts, err := repo.With(ctx, db).FindPage(
    func(db *gorm.DB, cls *Tアカウント情報Columns) *gorm.DB {
        return db.Where(cls.N年齢.Gte(18))
    },
    func(cls *Tアカウント情報Columns) gormcnm.OrderByBottle {
        return cls.ID.OrderByBottle("DESC")
    },
    &gormrepo.Pagination{Limit: 10, Offset: 0},
)

// Create
err := repo.With(ctx, db).Create(&Tアカウント情報{Aアカウント: "suzuki", Nニックネーム: "鈴木花子", N年齢: 25})

// Update
err := repo.With(ctx, db).Updates(
    func(db *gorm.DB, cls *Tアカウント情報Columns) *gorm.DB {
        return db.Where(cls.ID.Eq(1))
    },
    func(cls *Tアカウント情報Columns) map[string]interface{} {
        return cls.Kw(cls.N年齢.Kv(26)).AsMap()
    },
)

// Delete
err := repo.With(ctx, db).DeleteW(func(db *gorm.DB, cls *Tアカウント情報Columns) *gorm.DB {
    return db.Where(cls.ID.Eq(1))
})

한국어판:

// Create repo
repo := gormrepo.NewGormRepo(&T계정정보{}, (&T계정정보{}).Columns())

// Select - First (by username)
account, err := repo.With(ctx, db).First(func(db *gorm.DB, cls *T계정정보Columns) *gorm.DB {
    return db.Where(cls.G계정.Eq("kim-cheol-su"))
})

// Select - First (by nickname)
account, err := repo.With(ctx, db).First(func(db *gorm.DB, cls *T계정정보Columns) *gorm.DB {
    return db.Where(cls.N닉네임.Eq("김철수"))
})

// Select - Find
accounts, err := repo.With(ctx, db).Find(func(db *gorm.DB, cls *T계정정보Columns) *gorm.DB {
    return db.Where(cls.N나이.Gte(18))
})

// Select - FindPage
accounts, err := repo.With(ctx, db).FindPage(
    func(db *gorm.DB, cls *T계정정보Columns) *gorm.DB {
        return db.Where(cls.N나이.Gte(18))
    },
    func(cls *T계정정보Columns) gormcnm.OrderByBottle {
        return cls.ID.OrderByBottle("DESC")
    },
    &gormrepo.Pagination{Limit: 10, Offset: 0},
)

// Create
err := repo.With(ctx, db).Create(&T계정정보{G계정: "lee-young-hee", N닉네임: "이영희", N나이: 25})

// Update
err := repo.With(ctx, db).Updates(
    func(db *gorm.DB, cls *T계정정보Columns) *gorm.DB {
        return db.Where(cls.ID.Eq(1))
    },
    func(cls *T계정정보Columns) map[string]interface{} {
        return cls.Kw(cls.N나이.Kv(26)).AsMap()
    },
)

// Delete
err := repo.With(ctx, db).DeleteW(func(db *gorm.DB, cls *T계정정보Columns) *gorm.DB {
    return db.Where(cls.ID.Eq(1))
})

📝 Complete Examples

Check examples DIR with complete integration examples


Explore the complete GORM ecosystem with these integrated packages:

Core Ecosystem
  • gormcnm - GORM foundation providing type-safe column operations and query builders
  • gormcngen - AST-based code generation engine with type-safe GORM operations
  • gormrepo - Repo pattern implementation with GORM best practices
  • gormmom - Native language GORM tag generation engine with smart column naming (this project)
  • gormzhcn - Complete Chinese programming interface with GORM

Each package targets different aspects of GORM development, including localization, type-safe operations, and code generation.


📄 License

MIT License - see LICENSE.


💬 Contact & Feedback

Contributions are welcome! Report bugs, suggest features, and contribute code:

  • 🐛 Mistake reports? Open an issue on GitHub with reproduction steps
  • 💡 Fresh ideas? Create an issue to discuss
  • 📖 Documentation confusing? Report it so we can improve
  • 🚀 Need new features? Share the use cases to help us understand requirements
  • Performance issue? Help us optimize through reporting slow operations
  • 🔧 Configuration problem? Ask questions about complex setups
  • 📢 Follow project progress? Watch the repo to get new releases and features
  • 🌟 Success stories? Share how this package improved the workflow
  • 💬 Feedback? We welcome suggestions and comments

🔧 Development

New code contributions, follow this process:

  1. Fork: Fork the repo on GitHub (using the webpage UI).
  2. Clone: Clone the forked project (git clone https://github.com/yourname/repo-name.git).
  3. Navigate: Navigate to the cloned project (cd repo-name)
  4. Branch: Create a feature branch (git checkout -b feature/xxx).
  5. Code: Implement the changes with comprehensive tests
  6. Testing: (Golang project) Ensure tests pass (go test ./...) and follow Go code style conventions
  7. Documentation: Update documentation to support client-facing changes
  8. Stage: Stage changes (git add .)
  9. Commit: Commit changes (git commit -m "Add feature xxx") ensuring backward compatible code
  10. Push: Push to the branch (git push origin feature/xxx).
  11. PR: Open a merge request on GitHub (on the GitHub webpage) with detailed description.

Please ensure tests pass and include relevant documentation updates.


🌟 Support

Welcome to contribute to this project via submitting merge requests and reporting issues.

Project Support:

  • Give GitHub stars if this project helps you
  • 🤝 Share with teammates and (golang) programming friends
  • 📝 Write tech blogs about development tools and workflows - we provide content writing support
  • 🌟 Join the ecosystem - committed to supporting open source and the (golang) development scene

Have Fun Coding with this package! 🎉🎉🎉


📈 GitHub Stars

Stargazers

Documentation

Overview

Package gormmom: Native language programming engine that eliminates language constraints in database development As the smart tag generation engine of the GORM ecosystem, it empowers teams worldwide to write database models in native languages while auto generating database-compatible GORM tags and column names Supports Unicode-compatible field names in Chinese, Japanese, Korean, and additional languages

gormmom: 原生语言编程引擎,消除数据库开发中的语言限制 作为 GORM 生态系统的智能标签生成引擎,它赋能全球团队使用原生语言编写数据库模型 同时自动生成数据库兼容的 GORM 标签和列名 支持 Unicode 兼容的中文、日语、韩语和其他语言字段名

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeResult

type CodeResult struct {
	OutputCode       []byte // Generated code content // 生成的代码内容
	SourcePath       string // Source file path // 源文件路径
	ChangedLineCount int    // Number of lines changed // 更改的行数
}

CodeResult contains the result of code generation for a single file Includes the generated code, source path, and change statistics Used for tracking modifications during batch processing operations

CodeResult 包含单个文件的代码生成结果 包括生成的代码、源路径和更改统计 用于在批量处理操作期间跟踪修改

func (*CodeResult) HasChange

func (R *CodeResult) HasChange() bool

HasChange checks if this file result contains any changes Returns true if any lines were modified in this file

HasChange 检查此文件结果是否包含任何更改 如果此文件中有任何行被修改则返回 true

type CodeResults

type CodeResults struct {
	Items            []*CodeResult // Detailed results for each file // 每个文件的详细结果
	ChangedLineCount int           // Total number of changed lines // 更改的总行数
	ChangedFileCount int           // Total number of changed files // 更改的文件总数
}

CodeResults contains the result of batch code generation and replacement Provides statistics about changed lines and files during processing Includes detailed results for each processed file with change tracking

CodeResults 包含批量代码生成和替换的结果 提供处理过程中更改的行数和文件统计 包含每个处理文件的详细结果和更改跟踪

func (*CodeResults) HasChange

func (R *CodeResults) HasChange() bool

HasChange checks if any changes were made during batch processing Returns true if any lines or files were modified

HasChange 检查批量处理过程中是否有任何更改 如果任何行或文件被修改则返回 true

type Config

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

Config represents the configuration for GORM tag generation operations Contains the target struct information and generation options with customizing output Provides smart mapping and deterministic generation of database-compatible tags

Config 代表 GORM 标签生成操作的配置 包含目标结构体信息和生成选项,用于自定义输出 提供智能映射和确定性的数据库兼容标签生成

func NewConfig

func NewConfig(structI *GormStruct, options *Options) *Config

NewConfig creates a new configuration instance with GORM tag generation Takes the target struct and generation options, returns configured instance Used to initialize the generation workflow with custom settings

NewConfig 创建新的 GORM 标签生成配置实例 接收目标结构体和生成选项,返回配置好的实例 用于使用自定义设置初始化生成工作流程

func (*Config) Generate

func (cfg *Config) Generate() *CodeResult

Generate generates new GORM tags and replaces the original source file Processes the struct definition to add database-compatible tags and column names Formats the generated code and writes back to the source file when changes detected Returns the result containing the new code and change status

Generate 生成新的 GORM 标签并替换原始源文件 处理结构体定义以添加数据库兼容的标签和列名 检测到变化时自动格式化生成的代码并写回源文件 返回包含新代码和变化状态的结果

func (*Config) Preview

func (cfg *Config) Preview() *CodeResult

Preview generates new code with GORM tags without modifying the original file Reads the source file and processes it to add native language field mappings Returns the new code result with updated tags and column definitions

Preview 生成带有 GORM 标签的新代码而不修改原文件 读取源文件并处理以添加原生语言字段映射 返回包含更新标签和列定义的新代码结果

type Configs

type Configs []*Config

Configs represents a collection of configuration instances for batch processing Enables processing multiple GORM structures in a single operation Provides batch generation and file modification capabilities

Configs 代表一集配置实例,用于批量处理 允许在单个操作中处理多个 GORM 结构 提供批量生成和文件修改功能

func NewConfigs

func NewConfigs(structs []*GormStruct, options *Options) Configs

NewConfigs creates a batch configuration from GORM structures and options Processes multiple GORM structures with consistent options settings Returns configured batch prepared for tag generation and file modification

NewConfigs 从 GORM 结构和选项创建批量配置 使用一致的选项设置处理多个 GORM 结构 返回配置好的批量操作,准备进行标签生成和文件修改

func (Configs) Generate

func (configs Configs) Generate() *CodeResults

Generate performs batch code generation and file replacement operations Processes all configurations and applies changes to source files with formatting Returns comprehensive results with statistics about modifications made

Generate 执行批量代码生成和文件替换操作 处理所有配置并将更改带格式化地应用到源文件 返回包含修改统计的全面结果

func (Configs) Preview

func (configs Configs) Preview() *CodeResults

Preview performs batch code generation without modifying source files Processes all configurations and returns generated code without writing to disk Returns comprehensive results with statistics about potential modifications

Preview 执行批量代码生成但不修改源文件 处理所有配置并返回生成的代码而不写入磁盘 返回包含潜在修改统计的全面结果

func (Configs) ValidateGormTags

func (configs Configs) ValidateGormTags() error

ValidateGormTags validates GORM tags to ensure naming conventions Checks to find non-ASCII characters in index names and tag issues Returns each detected issue as an error

ValidateGormTags 验证 GORM 标签的命名规范 检查索引名中的非 ASCII 字符和其他标签问题 如果发现问题标签则返回错误

type GormStruct

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

GormStruct represents a GORM struct with its location and field information Contains the source file path, struct name, and comprehensive field mappings Provides structured access to GORM schema and field definitions for processing Maintains ordered field mapping using linked hash map for deterministic generation

GormStruct 代表一个 GORM 结构体及其位置和字段信息 包含源文件路径、结构体名称和全面的字段映射 为处理提供对 GORM 模式和字段定义的结构化访问 使用链式哈希映射维护有序字段映射,确保确定性生成

func NewGormStruct

func NewGormStruct(sourcePath string, structName string, gormSchema *schema.Schema) *GormStruct

NewGormStruct creates a new GormStruct instance with field information Reads and processes struct field information from the source file and GORM schema Builds ordered field mapping for deterministic tag generation and processing Returns configured GormStruct prepared for native language tag processing

NewGormStruct 创建新的 GormStruct 实例并读取字段信息 从源文件和 GORM 模式中读取和处理结构体字段信息 构建有序字段映射以进行确定性标签生成和处理 返回配置好的 GormStruct,准备进行原生语言标签处理

func ParseObject

func ParseObject(sourcePath string, object interface{}) *GormStruct

ParseObject creates GormStruct from an object instance Accepts both struct value and struct pointer as the object parameter Returns configured GormStruct with schema information extracted from object

ParseObject 从对象实例创建 GormStruct object 参数可以传对象值或对象指针 返回配置好的 GormStruct,包含从对象中提取的模式信息

func ParseObjects

func ParseObjects(root string, objects []interface{}) []*GormStruct

ParseObjects creates multiple GormStruct instances from a collection of objects Scans Go files in the root DIR to locate struct definitions and build mappings Uses ordered map to ensure deterministic processing sequence across executions Returns slice of configured GormStruct instances matched with source locations

ParseObjects 从对象集合创建多个 GormStruct 实例 扫描根 DIR 中的 Go 文件以定位结构体定义并构建映射 使用有序映射确保跨执行的确定性处理顺序 返回与源代码位置匹配的配置好的 GormStruct 实例切片

func ParseStruct

func ParseStruct[StructType any](sourcePath string) *GormStruct

ParseStruct creates GormStruct using generic type parameter T must be the struct type name without pointer (e.g., User not *User) Returns configured GormStruct with schema information extracted from type

ParseStruct 使用泛型类型参数创建 GormStruct T 只能传类型名称而非带指针的类型名(如 User 而非 *User) 返回配置好的 GormStruct,包含从类型中提取的模式信息

type Options

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

Options represents configuration settings for GORM tag generation Contains naming strategies and behavior controls with native language field processing Provides customizable tag names, column naming rules, and index generation settings Supports smart skipping of basic fields and flexible configuration options

Options 代表 GORM 标签生成的配置设置 包含原生语言字段处理的命名策略和行为控制 提供可自定义的标签名称、列命名规则和索引生成设置 支持智能跳过基础字段和灵活的配置选项

func NewOptions

func NewOptions() *Options

NewOptions creates a new Options instance with default settings optimized with native language processing Initializes with smart defaults including tag naming, column strategies, and index generation Returns configured options prepared for GORM tag generation with Unicode field support

NewOptions 创建新的选项实例,使用针对原生语言处理优化的默认设置 使用智能默认值初始化,包括标签命名、列策略和索引生成 返回配置好的选项,准备进行支持 Unicode 字段的 GORM 标签生成

func (*Options) WithAutoIndexName

func (opt *Options) WithAutoIndexName(autoIndexName bool) *Options

WithAutoIndexName enables or disables index name regeneration When true, index names are regenerated based on configured patterns Returns the Options instance to enable method chaining

WithAutoIndexName 启用或禁用索引名重新生成 当为 true 时,索引名基于配置的模式重新生成 返回 Options 实例以启用方法链

func (*Options) WithColumnPattern

func (opt *Options) WithColumnPattern(pattern gormmomname.Pattern) *Options

WithColumnPattern registers a custom column naming pattern Adds the pattern to the strategies collection for column name generation Returns the Options instance to enable method chaining

WithColumnPattern 注册自定义的列命名模式 将模式添加到列名生成的策略集合中 返回 Options 实例以启用方法链

func (*Options) WithDefaultColumnPattern

func (opt *Options) WithDefaultColumnPattern(pattern gormmomname.Pattern) *Options

WithDefaultColumnPattern sets the default column naming pattern Used when no specific pattern is configured in struct tags Returns the Options instance to enable method chaining

WithDefaultColumnPattern 设置默认的列命名模式 当结构体标签中没有配置特定模式时使用 返回 Options 实例以启用方法链

func (*Options) WithDefaultIndexPattern

func (opt *Options) WithDefaultIndexPattern(pattern gormidxname.Pattern) *Options

WithDefaultIndexPattern sets the default index naming pattern Used when no specific pattern is configured for index generation Returns the Options instance to enable method chaining

WithDefaultIndexPattern 设置默认的索引命名模式 当索引生成没有配置特定模式时使用 返回 Options 实例以启用方法链

func (*Options) WithIndexPattern

func (opt *Options) WithIndexPattern(pattern gormidxname.Pattern) *Options

WithIndexPattern registers a custom index naming pattern Adds the pattern to the strategies collection for index name generation Returns the Options instance to enable method chaining

WithIndexPattern 注册自定义的索引命名模式 将模式添加到索引名生成的策略集合中 返回 Options 实例以启用方法链

func (*Options) WithSkipBasicColumnName

func (opt *Options) WithSkipBasicColumnName(skipBasicColumnName bool) *Options

WithSkipBasicColumnName enables or disables skipping of basic column names When true, fields with standard ASCII column names are skipped Returns the Options instance to enable method chaining

WithSkipBasicColumnName 启用或禁用跳过基本列名 当为 true 时,具有标准 ASCII 列名的字段被跳过 返回 Options 实例以启用方法链

func (*Options) WithSubTagName

func (opt *Options) WithSubTagName(subTagName string) *Options

WithSubTagName sets the sub-tag name for column naming patterns Configures the nested tag field name within the system tag Returns the Options instance to enable method chaining

WithSubTagName 设置列命名模式的子标签名 配置系统标签内的嵌套标签字段名 返回 Options 实例以启用方法链

func (*Options) WithTagName

func (opt *Options) WithTagName(systemTagName string) *Options

WithTagName sets the system tag name used in struct tags Configures the tag key name that gormmom uses to store pattern information Returns the Options instance to enable method chaining

WithTagName 设置结构体标签中使用的系统标签名 配置 gormmom 用于存储模式信息的标签键名 返回 Options 实例以启用方法链

Directories

Path Synopsis
Package gormidxname: Database index naming strategy engine for GORM optimization Provides intelligent index name generation from Unicode field names with pattern-based validation Supports multiple naming strategies including lowercase and uppercase patterns with length constraints Ensures cross-database compatibility by implementing intersection of various database index naming rules
Package gormidxname: Database index naming strategy engine for GORM optimization Provides intelligent index name generation from Unicode field names with pattern-based validation Supports multiple naming strategies including lowercase and uppercase patterns with length constraints Ensures cross-database compatibility by implementing intersection of various database index naming rules
Package gormmomname: Native language column name generation strategies for database compatibility Provides pattern-based column name generation from Unicode field names to database-safe identifiers Supports multiple naming strategies including lowercase and uppercase patterns with length constraints Ensures cross-database compatibility by implementing intersection of various database naming rules
Package gormmomname: Native language column name generation strategies for database compatibility Provides pattern-based column name generation from Unicode field names to database-safe identifiers Supports multiple naming strategies including lowercase and uppercase patterns with length constraints Ensures cross-database compatibility by implementing intersection of various database naming rules
internal

Jump to

Keyboard shortcuts

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