{"id":15485874,"url":"https://github.com/licoy/dbstruct","last_synced_at":"2025-10-15T00:11:03.807Z","repository":{"id":57550470,"uuid":"308243509","full_name":"Licoy/dbstruct","owner":"Licoy","description":"dbstruct是一款将数据库表一键转换为Golang Struct的应用程序，支持自定义Tag和多种命名格式配置。","archived":false,"fork":false,"pushed_at":"2022-09-28T08:39:13.000Z","size":28,"stargazers_count":28,"open_issues_count":0,"forks_count":14,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-17T04:19:25.771Z","etag":null,"topics":["generator","go","golang","gosql","goutils","mysql"],"latest_commit_sha":null,"homepage":"","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/Licoy.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}},"created_at":"2020-10-29T06:56:26.000Z","updated_at":"2024-05-25T01:44:14.000Z","dependencies_parsed_at":"2022-08-29T22:30:55.893Z","dependency_job_id":null,"html_url":"https://github.com/Licoy/dbstruct","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Licoy%2Fdbstruct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Licoy%2Fdbstruct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Licoy%2Fdbstruct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Licoy%2Fdbstruct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Licoy","download_url":"https://codeload.github.com/Licoy/dbstruct/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250269953,"owners_count":21402970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["generator","go","golang","gosql","goutils","mysql"],"created_at":"2024-10-02T06:04:09.684Z","updated_at":"2025-10-06T20:47:10.362Z","avatar_url":"https://github.com/Licoy.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 介绍\n`dbstruct`是一款将数据库表一键转换为Golang Struct的应用程序，支持自定义Tag和多种命名格式配置。\n## 参数列表\n```go\ndsn              string   //数据库链接\ntables           []string //自定义表\ntagJson          bool     //json tag\ntagOrm           bool     //orm tag\nfieldNameFmt     FmtMode  //字段名称格式\nstructNameFmt    FmtMode  //结构名格式\nfileNameFmt      FmtMode  //文件名格式\ngenTableName     string   //TableName方法名，\ngenTableNameFunc bool     //是否生成TableName方法\nmodelPath        string   //model保存的路径，若singleFile==true，则填写model.go的完整路径，默认为当前路径\nsingleFile       bool     //是否合成一个单文件\npackageName      string   //包名\ntags             []*Tag   //自定义Tag列表\n```\n## 使用方法\n### 安装依赖\n```shell script\ngo get github.com/Licoy/dbstruct\n```\n### 使用\n```go\nerr := dbstruct.NewDBStruct().\n    Dsn(\"root:root@tcp(127.0.0.1:3306)/dbname?charset=utf8\").\n    StructNameFmt(dbstruct.FmtUnderlineToStartUpHump).\n    FieldNameFmt(dbstruct.FmtUnderlineToStartUpHump).\n    FileNameFmt(dbstruct.FmtUnderline).\n    //SingleFile(true).\n    GenTableNameFunc(true).\n    GenTableName(\"TableName\").\n    TagJson(true).\n    PackageName(\"model\").\n    TagOrm(true).\n    AppendTag(dbstruct.NewTag(\"xml\", dbstruct.FmtDefault)).\n    Generate()\nif err != nil {\n    fmt.Println(err)\n}\n```\n### 生成结果示例\n```go\npackage model\n\ntype Mart struct {\n\tId         int64 `xml:\"id\" json:\"id\" orm:\"id\" `\n\tActId      int64 `xml:\"act_id\" json:\"act_id\" orm:\"act_id\" `\n\tCreated    int64 `xml:\"created\" json:\"created\" orm:\"created\" `\n\tTemplateId int   `xml:\"template_id\" json:\"template_id\" orm:\"template_id\" `\n\tNumber     int   `xml:\"number\" json:\"number\" orm:\"number\" `\n\tPrice      int   `xml:\"price\" json:\"price\" orm:\"price\" `\n\tDay        int   `xml:\"day\" json:\"day\" orm:\"day\" `\n}\n\nfunc (m *Mart) MyTableName() string {\n\treturn \"mart\"\n}\n```\n## 授权\n[MIT](./LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flicoy%2Fdbstruct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flicoy%2Fdbstruct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flicoy%2Fdbstruct/lists"}