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 ¶
- type CodeResult
- type CodeResults
- type Config
- type Configs
- type GormStruct
- type Options
- func (opt *Options) WithAutoIndexName(autoIndexName bool) *Options
- func (opt *Options) WithColumnPattern(pattern gormmomname.Pattern) *Options
- func (opt *Options) WithDefaultColumnPattern(pattern gormmomname.Pattern) *Options
- func (opt *Options) WithDefaultIndexPattern(pattern gormidxname.Pattern) *Options
- func (opt *Options) WithIndexPattern(pattern gormidxname.Pattern) *Options
- func (opt *Options) WithSkipBasicColumnName(skipBasicColumnName bool) *Options
- func (opt *Options) WithSubTagName(subTagName string) *Options
- func (opt *Options) WithTagName(systemTagName string) *Options
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 实例以启用方法链
Source Files
¶
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
|
|