1 Star 2 Fork 0

o0无忧亦无怖/gmodel

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.19 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"flag"
"fmt"
"github.com/go-libraries/gmodel/generator"
"os"
)
var (
modelPath string
driver string
dsn string
ignoreTable string
style string
packageName string
help bool
h bool
)
func init() {
currentPath, _ := os.Getwd()
flag.StringVar(&modelPath, "dir", currentPath, "a dir name save model file path, default is current path")
flag.StringVar(&driver, "driver", "mysql", "database driver,like `mysql` `mariadb`, default is mysql")
flag.StringVar(&dsn, "dsn", "", "connection info names dsn")
flag.StringVar(&ignoreTable, "ig_tables", "", "ignore table names")
flag.StringVar(&style, "style", "default", "use orm style like `bee` `gorm`, default `default`")
flag.StringVar(&packageName, "package", "", "help")
flag.BoolVar(&help, "help", false, "this help")
flag.BoolVar(&h, "h", false, "this help")
}
func main() {
flag.Parse()
if h {
flag.Usage()
}
if dsn == "" {
flag.Usage()
}
flag.Usage = usage
generator.GetDriver(modelPath, driver, dsn, style, packageName).Run()
}
func usage() {
fmt.Println("Usage: model [-dir dirname] [-driver mysql] [-dsn username:password@tcp(host:port)/database]")
flag.PrintDefaults()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/Mars_Lee/gmodel.git
git@gitee.com:Mars_Lee/gmodel.git
Mars_Lee
gmodel
gmodel
master

搜索帮助