{"id":34230212,"url":"https://github.com/sudo-keke/gotable","last_synced_at":"2026-03-10T16:11:41.688Z","repository":{"id":41285569,"uuid":"501088552","full_name":"sudo-keke/gotable","owner":"sudo-keke","description":":zap: 生成数据库表的go结构体","archived":false,"fork":false,"pushed_at":"2023-12-20T07:34:55.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-21T13:06:32.217Z","etag":null,"topics":["go","golang","gorm","gorm-model","struct"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sudo-keke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-08T03:37:57.000Z","updated_at":"2023-12-20T07:30:15.000Z","dependencies_parsed_at":"2022-07-07T04:03:31.038Z","dependency_job_id":null,"html_url":"https://github.com/sudo-keke/gotable","commit_stats":null,"previous_names":["sudo-keke/tostruct"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/sudo-keke/gotable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudo-keke%2Fgotable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudo-keke%2Fgotable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudo-keke%2Fgotable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudo-keke%2Fgotable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sudo-keke","download_url":"https://codeload.github.com/sudo-keke/gotable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudo-keke%2Fgotable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30342148,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T15:55:29.454Z","status":"ssl_error","status_checked_at":"2026-03-10T15:54:58.440Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["go","golang","gorm","gorm-model","struct"],"created_at":"2025-12-16T01:01:38.595Z","updated_at":"2026-03-10T16:11:41.681Z","avatar_url":"https://github.com/sudo-keke.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gotable ⚡\n\n\n\n### 🔨 生成数据库对应的go模型文件\n\n\n---\n\n点击此处打开测试文件  `--\u003e`   [✅ main.go](./main/main.go)\n\n🌱 使用方法： 复制以下代码片段即可\n    \n### ⏩ go.mod（示例）\n```go\n\nmodule XXXX\n\n// 1.17+\ngo 1.18\n\nrequire (\n\tgotable v1.3.0\n)\n\n// 重命名为 gotable，建议使用最新版本\nreplace gotable =\u003e github.com/sudo-keke/gotable v1.3.0\n\n\n```\n\n\n### ⏩ 单表生成（示例）\n```go\n// 引用 gotable，如果go.mod没重命名，则需要全路径\nimport (\n\t\"gotable/common\"\n\t\"gotable/config\"\n)\n\nfunc Single() {\n\thandler := config.NewTblToStructHandler()\n\thandler.\n\t\t//设置数据库dsn连接地址\n\t\tSetConnectByDSN(user+\":\"+password+\"@(\"+host+\":\"+port+\")/\"+db+\"?charset=utf8mb4\u0026parseTime=True\u0026loc=Local\").\n\t\t//生成哪张数据库表的结构\n\t\tSetTableName(TableName).\n\t\t//文件最上面一行的包名称 SetPackage(\"包名\",\"前缀\",\"后缀\")\n\t\tSetPackage(SavePackage, \"\", \"\").\n\t\t//保存到什么位置\n\t\tSetSavePath(SavePath).\n\t\t//单表可以指定生成的struct的名称和格式(单表生成时使用)\n        SetStructNameConfig(common.CamelCase, StructName).\n\t\t//ORM标签信息, SetStructOrmTag(\"gorm\",\"是否生成type标签\",\"是否生成PRIMARY KEY标签\",\"是否生成NOT NULL标签\")\n\t\tSetStructOrmTag(common.GORM, true, true, true).\n\t\t//扩展标签信息\n\t\tSetOtherTag(common.JSON).\n\t\t//时间类型要生成什么格式\n\t\tSetTimeType(common.TimeTypeTime).\n\t\t//设置struct中字段的格式\n\t\tSetStructColumnName(common.CamelCase, common.FieldOrderFollowDB, \"\", \"\")\n\n\t//生成\n\tconfig.GenerateTblStruct(handler)\n}\n```\n\n---\n\n### ⏩ 多表生成（示例）\n\n```go\n\nfunc Multiple() {\n\thandler := config.NewTblToStructHandler()\n\thandler.\n\t\t//设置数据库dsn连接地址\n\t\tSetConnectByDSN(user+\":\"+password+\"@(\"+host+\":\"+port+\")/\"+db+\"?charset=utf8mb4\u0026parseTime=True\u0026loc=Local\").\n\t\t//生成哪张数据库表的结构\n\t\tSetTableNames(TableNames).\n\t\t//文件最上面一行的包名称 SetPackage(\"包名\",\"前缀\",\"后缀\")\n\t\tSetPackage(SavePackage, \"\", \"\").\n\t\t//保存到什么位置\n\t\tSetSavePath(SavePath).\n\t\t//多表生成不可指定struct的名称，但可以设置格式(多表生成时使用)\n\t\tSetManyStructNameConfig(common.CamelCase, \"\", \"\").\n\t\t//ORM标签信息, SetStructOrmTag(\"gorm\",\"是否生成type标签\",\"是否生成PRIMARY KEY标签\",\"是否生成NOT NULL标签\")\n\t\tSetStructOrmTag(common.GORM, true, true, true).\n\t\t//扩展标签信息\n\t\tSetOtherTag(common.JSON).\n\t\t//时间类型要生成什么格式\n\t\tSetTimeType(common.TimeTypeTime).\n\t\t//设置struct中字段的格式\n\t\tSetStructColumnName(common.CamelCase, common.FieldOrderFollowDB, \"\", \"\")\n\n\t//生成\n\tconfig.GenerateAllTblStruct(handler)\n}\n```\n\n\n---\n\n🚥 有问题可以提 issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsudo-keke%2Fgotable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsudo-keke%2Fgotable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsudo-keke%2Fgotable/lists"}