Skip to content
/ gormmom Public

Empowering Native Language Programming, Simplifying GORM Tag Generation

License

Notifications You must be signed in to change notification settings

yyle88/gormmom

Repository files navigation

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

gormmom

Empowering Native Language Programming, Simplifying GORM Tag Generation


gormmom is a tool designed to automatically generate GORM tags, aimed at helping developers program in their native language while simplifying the process of defining GORM tags. The tool processes struct fields and automatically generates GORM-compliant tags, ensuring field names follow specific naming conventions.


CHINESE README

中文说明


Features

  • Automatic GORM Tag Generation: Automatically generates GORM tags for struct fields, such as column, index, unique, etc.
  • Native Language Programming Support: Allows developers to define struct fields in their native language (e.g., Chinese), reducing the difficulty of understanding business.

Installation

go get github.com/yyle88/gormmom

Usage Example

Original Code (Native Language Programming)

type Example struct {
    V证号 string `gorm:"primaryKey"`
    V姓名 string `gorm:"index"`
    V年龄 int    `gorm:"unique"`
    V性别 bool   `gorm:"column:sex;uniqueIndex" mom:"naming:S63"`
}

Generated Code (Automatic GORM Tag Generation)

type Example struct {
    V证号 string `gorm:"column:v_c18b_f753;primaryKey" mom:"naming:s63;"`
    V姓名 string `gorm:"column:v_d359_0d54;index:idx_example_v_d359_0d54" mom:"naming:s63;idx:cnm;"`
    V年龄 int    `gorm:"column:v_745e_849f;unique" mom:"naming:s63;"`
    V性别 bool   `gorm:"column:V_2760_2B52;uniqueIndex:udx_example_V_2760_2B52" mom:"naming:S63;udx:cnm;"`
}

Configuration Options

  • naming: Configures the naming convention for database column names.
  • idx: Configures the naming convention for single-column indexes.
  • udx: Configures the naming convention for single-column unique indexes.

Design Ideas

README OLD DOC


License

gormmom is open-source and released under the MIT License. See the LICENSE file for more information.


Support

Welcome to contribute to this project by submitting pull requests or reporting issues.

If you find this package helpful, give it a star on GitHub!

Thank you for your support!

Happy Coding with gormmom! 🎉

Give me stars. Thank you!!!

See stars

see stars