# modeltools **Repository Path**: lb-jwz/modeltools ## Basic Information - **Project Name**: modeltools - **Description**: 一款可以根据数据库字段生成go model的插件 - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2020-09-27 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Modeltools #### GO语言连接Mysql生成对应的model,包括对应字段类型、注释等。生成基础的结构体,不局限于某一个ORM。 **参数配置--------conf.go** ```go package conf // model保存路径 const ModelPath = "./models/" // 是否覆盖已存在model const ModelReplace = true // 数据库驱动 const DriverName = "mysql" type DbConf struct { Host string Port string User string Pwd string DbName string } // 数据库链接配置 var MasterDbConfig DbConf = DbConf{ Host: "127.0.0.1", Port: "3306", User: "root", Pwd: "long", DbName: "mvideo", } ``` **生成model--------** ```go package main import ( "modeltools/dbtools" "modeltools/generate" ) func main() { //初始化数据库 dbtools.Init() //generate.Genertate() //生成所有表信息 generate.Genertate("admin_info","video_info") //生成指定表信息,可变参数可传入多个表名 } ```