{"id":51497035,"url":"https://github.com/yylego/gormzhcn","last_synced_at":"2026-07-07T16:30:32.300Z","repository":{"id":369461769,"uuid":"1178577328","full_name":"yylego/gormzhcn","owner":"yylego","description":"Chinese programming interface with GORM ecosystem, enabling native Chinese field names in database operations","archived":false,"fork":false,"pushed_at":"2026-06-30T03:37:31.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-05T14:09:34.081Z","etag":null,"topics":["chinese-programming","gorm","gorm-tag-generation","unicode-identifiers"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yylego.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-11T06:43:34.000Z","updated_at":"2026-06-30T03:32:54.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/yylego/gormzhcn","commit_stats":null,"previous_names":["yylego/gormzhcn"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/yylego/gormzhcn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yylego%2Fgormzhcn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yylego%2Fgormzhcn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yylego%2Fgormzhcn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yylego%2Fgormzhcn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yylego","download_url":"https://codeload.github.com/yylego/gormzhcn/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yylego%2Fgormzhcn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35235814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-07T02:00:07.222Z","response_time":90,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chinese-programming","gorm","gorm-tag-generation","unicode-identifiers"],"created_at":"2026-07-07T16:30:31.185Z","updated_at":"2026-07-07T16:30:32.283Z","avatar_url":"https://github.com/yylego.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/yylego/gormzhcn/release.yml?branch=main\u0026label=BUILD)](https://github.com/yylego/gormzhcn/actions/workflows/release.yml?query=branch%3Amain)\n[![GoDoc](https://pkg.go.dev/badge/github.com/yylego/gormzhcn)](https://pkg.go.dev/github.com/yylego/gormzhcn)\n[![Coverage Status](https://img.shields.io/coveralls/github/yylego/gormzhcn/main.svg)](https://coveralls.io/github/yylego/gormzhcn?branch=main)\n[![Supported Go Versions](https://img.shields.io/badge/Go-1.25+-lightgrey.svg)](https://go.dev/)\n[![GitHub Release](https://img.shields.io/github/release/yylego/gormzhcn.svg)](https://github.com/yylego/gormzhcn/releases)\n[![Go Report Card](https://goreportcard.com/badge/github.com/yylego/gormzhcn)](https://goreportcard.com/report/github.com/yylego/gormzhcn)\n\n# 🇨🇳 GORMZHCN - Chinese GORM Naming Guardian\n\n**gormzhcn** puts a **Chinese-localized interface** on gormmom naming validation. Write GORM models with native Chinese fields, then **guard** that each database name a struct produces — the table name, each column name, each index name — stays database-safe, through intuitive Chinese type and method names. It runs as a plain unit test and touches no database.\n\n\u003e 🎯 **Code in Chinese, ship database-safe schemas.** gormzhcn catches Chinese names that a database would reject — long before such names reach the database.\n\n## Ecosystem\n\n![GORM Type-Safe Ecosystem](https://github.com/yylego/gormcnm/raw/main/assets/gormcnm-ecosystem.svg)\n\n---\n\n\u003c!-- TEMPLATE (EN) BEGIN: LANGUAGE NAVIGATION --\u003e\n\n## CHINESE README\n\n[中文说明](README.zh.md)\n\n\u003c!-- TEMPLATE (EN) END: LANGUAGE NAVIGATION --\u003e\n\n---\n\n## DISCLAIMER\n\nWriting Go code in Chinese is a viable technique, but something to avoid in production engineering. This approach should not be used in serious and business settings. Teams and companies that embrace it could face contempt from peers and negative judgment across the profession. In business companies, this practice often becomes a target of public criticism. This project is dedicated to research and academic studies. Do not use this approach in production.\n\n---\n\n## 🤖 How gormzhcn became just a guardian (the AI-era simplification)\n\ngormzhcn used to wrap a **generation engine**: you wrote Chinese fields, tags left blank, and it auto-synthesized the column names and index names on its own (pinyin and pattern-based encodings).\n\n**The AI era made that generation pointless.** The moment you define a field, an AI assistant gives you a good, database-safe column name — in context, a cut above a fixed rule engine. A machine-synthesized `z_zhang_hao` was not what someone wanted. So the entire generation step lost its reason to exist.\n\nWhat AI does **not** hand you on its own is the part that bites: **validation**. When you program in Chinese, GORM might turn a field into a non-ASCII column name, and it can build a composite index name out of Chinese field names — names the database rejects. That failure shows up late, at migration time, at runtime.\n\nSo gormzhcn dropped generation outright and now does just one thing: **catch those naming problems in a database-free unit test**, so none of them blow up in production.\n\n- ❌ Gone: code generation, pinyin/pattern column synthesis, the old code-gen types.\n- ✅ Kept: one job — validate that the table / column / index names are database-safe.\n- ✅ Zero database connection — a pure static check that runs as a plain unit test.\n\n---\n\n## 🚀 Installation\n\n```bash\ngo get github.com/yylego/gormzhcn\n```\n\n---\n\n## 🌟 The Problem \u0026 Solution\n\n### ⚡ The trap of Chinese-language models\n\nChinese fields read great, but the names GORM derives from them can be names the database refuses:\n\n```go\ntype T账户信息 struct {\n    ID   uint   `gorm:\"primaryKey\"`\n    Z账号 string `gorm:\"uniqueIndex\"` // ❌ no index name → GORM builds one from the field name → non-ASCII → rejected\n    N昵称 string `gorm:\"\"`            // ❌ no column name → column falls back to a non-ASCII name → rejected\n}\n```\n\n### ✅ The gormzhcn approach\n\nKeep the Chinese field names, but give explicit database-safe column / index / table names — and let gormzhcn guard them in a unit test:\n\n```go\ntype T账户信息 struct {\n    ID   uint   `gorm:\"primaryKey\"`\n    Z账号 string `gorm:\"column:account;uniqueIndex:udx_account\"`\n    N昵称 string `gorm:\"column:nickname;index:idx_nickname\"`\n    A年龄 int    `gorm:\"column:age\"`\n    S状态 string `gorm:\"column:status;index:idx_status\"`\n}\n\nfunc (*T账户信息) TableName() string {\n    return \"accounts\" // database-safe ASCII table name\n}\n```\n\n---\n\n## 🛠️ Usage — validate in a unit test\n\ngormzhcn opens no database connection; it runs as a plain unit test:\n\n```go\nfunc TestValidateNaming(t *testing.T) {\n    objects := []interface{}{\n        \u0026T账户信息{},\n    }\n\n    // Guard a batch: table / column / index names must be database-safe.\n    require.NoError(t, gormzhcn.NewT模型校验器(objects, gormzhcn.NewT配置项()).Validate())\n\n    // Guard a single struct on its own.\n    require.NoError(t, gormzhcn.NewT校验器(\u0026T账户信息{}, gormzhcn.NewT配置项()).Validate())\n}\n```\n\nA failing name comes back as a precise message — naming the struct, the offending name, and the field when one applies — caught long before a migration. The name length cap and the GORM naming strategy are tunable:\n\n```go\nv配置项 := gormzhcn.NewT配置项().\n    With最大名字长度(63).        // name length cap (Postgres uses 63)\n    With命名策略(schema.NamingStrategy{}) // pass a custom strategy when a project needs one\n```\n\n---\n\n## 🤝 Use with the ecosystem\n\ngormzhcn guards the naming; its sibling packages handle type-safe columns and repo-style CRUD. A common flow, start to finish in Chinese:\n\n**1. Define a Chinese struct** with explicit database-safe names (see above): a `T学生` with fields `V名字`, `V性别`, `V班级编码`, ...\n\n**2. Guard the naming with gormzhcn** — a database-free unit test:\n\n```go\nrequire.NoError(t, gormzhcn.NewT模型校验器([]interface{}{\u0026T学生{}}, gormzhcn.NewT配置项()).Validate())\n```\n\n**3. Generate type-safe columns with [gormcngen](https://github.com/yylego/gormcngen)**:\n\n```go\ngormcngen.NewConfigs([]interface{}{\u0026T学生{}}, gormcngen.NewOptions().WithUseTagName(true), srcPath).Gen()\n// → produces T学生Columns with Chinese columns: V名字, V性别, V班级编码, ...\n```\n\n**4. Run queries with [gormrepo](https://github.com/yylego/gormrepo)** through the Chinese columns:\n\n```go\nrepo := gormrepo.NewRepo(gormclass.Use(\u0026T学生{}))\nstudent, err := repo.Repo(db).First(func(db *gorm.DB, cls *T学生Columns) *gorm.DB {\n    return db.Where(cls.V名字.Eq(\"杨亦乐\"))\n})\n```\n\nComplete runnable examples live in [examples](internal/examples/).\n\n---\n\n## 🔧 API Reference\n\n| Chinese name                      | Wraps                | Description                             |\n| --------------------------------- | -------------------- | --------------------------------------- |\n| `NewT模型校验器(objects, 配置项)` | `gormmom.NewConfigs` | Build a batch check                     |\n| `T模型校验器.Validate()`          | `Configs.Validate`   | Validate the whole batch                |\n| `NewT校验器(object, 配置项)`      | `gormmom.NewConfig`  | Build a single-struct check             |\n| `T校验器.Validate()`              | `Config.Validate`    | Validate one struct                     |\n| `NewT配置项()`                    | `gormmom.NewOptions` | Build a config                          |\n| `With最大名字长度(n)`             | `WithMaxNameLength`  | Set the name length cap                 |\n| `With命名策略(namer)`             | `WithNamingStrategy` | Set the GORM naming strategy            |\n| `GetOptions()`                    | —                    | Access the underlying `gormmom.Options` |\n\n---\n\n## Related Projects\n\nExplore the complete GORM ecosystem with these integrated packages:\n\n### Core Ecosystem\n\n- **[gormcnm](https://github.com/yylego/gormcnm)** - GORM base package with type-safe columns and statement building\n- **[gormcngen](https://github.com/yylego/gormcngen)** - AST-based code generation with type-safe GORM operations\n- **[gormrepo](https://github.com/yylego/gormrepo)** - Repo pattern implementation with GORM best practices\n- **[gormmom](https://github.com/yylego/gormmom)** - Native language GORM naming guardian (the engine gormzhcn wraps)\n- **[gormzhcn](https://github.com/yylego/gormzhcn)** - Chinese GORM naming guardian (this package)\n\nThese packages handle GORM development aspects: localization, type protection, and naming validation.\n\n---\n\n\u003c!-- TEMPLATE (EN) BEGIN: STANDARD PROJECT FOOTER --\u003e\n\u003c!-- VERSION 2025-11-25 03:52:28.131064 +0000 UTC --\u003e\n\n## 📄 License\n\nMIT License - see [LICENSE](LICENSE).\n\n---\n\n## 💬 Contact \u0026 Feedback\n\nContributions are welcome! Report bugs, suggest features, and contribute code:\n\n- 🐛 **Mistake reports?** Open an issue on GitHub with reproduction steps\n- 💡 **Fresh ideas?** Create an issue to discuss\n- 📖 **Documentation confusing?** Report it so we can improve\n- 🚀 **Need new features?** Share the use cases to help us understand requirements\n- ⚡ **Performance issue?** Help us optimize through reporting slow operations\n- 🔧 **Configuration problem?** Ask questions about complex setups\n- 📢 **Follow project progress?** Watch the repo to get new releases and features\n- 🌟 **Success stories?** Share how this package improved the workflow\n- 💬 **Feedback?** We welcome suggestions and comments\n\n---\n\n## 🔧 Development\n\nNew code contributions, follow this process:\n\n1. **Fork**: Fork the repo on GitHub (using the webpage UI).\n2. **Clone**: Clone the forked project (`git clone https://github.com/yourname/repo-name.git`).\n3. **Navigate**: Navigate to the cloned project (`cd repo-name`)\n4. **Branch**: Create a feature branch (`git checkout -b feature/xxx`).\n5. **Code**: Implement the changes with comprehensive tests\n6. **Testing**: (Golang project) Ensure tests pass (`go test ./...`) and follow Go code style conventions\n7. **Documentation**: Update documentation to support client-facing changes\n8. **Stage**: Stage changes (`git add .`)\n9. **Commit**: Commit changes (`git commit -m \"Add feature xxx\"`) ensuring backward compatible code\n10. **Push**: Push to the branch (`git push origin feature/xxx`).\n11. **PR**: Open a merge request on GitHub (on the GitHub webpage) with detailed description.\n\nPlease ensure tests pass and include relevant documentation updates.\n\n---\n\n## 🌟 Support\n\nWelcome to contribute to this project via submitting merge requests and reporting issues.\n\n**Project Support:**\n\n- ⭐ **Give GitHub stars** if this project helps you\n- 🤝 **Share with teammates** and (golang) programming friends\n- 📝 **Write tech blogs** about development tools and workflows - we provide content writing support\n- 🌟 **Join the ecosystem** - committed to supporting open source and the (golang) development scene\n\n**Have Fun Coding with this package!** 🎉🎉🎉\n\n\u003c!-- TEMPLATE (EN) END: STANDARD PROJECT FOOTER --\u003e\n\n---\n\n## GitHub Stars\n\n[![Stargazers](https://starchart.cc/yylego/gormzhcn.svg?variant=adaptive)](https://starchart.cc/yylego/gormzhcn)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyylego%2Fgormzhcn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyylego%2Fgormzhcn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyylego%2Fgormzhcn/lists"}