Merge pull request #1 from xxjwxc/master

获取最新
This commit is contained in:
倒霉狐狸
2020-02-23 09:54:38 +08:00
committed by GitHub
33 changed files with 1153 additions and 130 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1,8 +1,19 @@
all:
make windows
make mac
make linux
make clear
windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o gormt.exe main.go
tar czvf gormt_windows.zip gormt.exe config.yml
mac:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o gormt main.go
tar czvf gormt_mac.zip gormt config.yml
linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gormt main.go
tar czvf gormt_linux.zip gormt config.yml
clear:
- rm -rf model/*
- rm -rf err/
- rm gormt
- rm gormt.exe

View File

@@ -7,24 +7,37 @@
## [中文文档](README_zh_cn.md)
### mysql database to goang struct conversion tools base on [gorm](https://github.com/jinzhu/gorm)You can automatically generate golang sturct from MySQL database.
### mysql database to goang struct conversion tools base on [gorm](https://github.com/jinzhu/gorm)You can automatically generate golang sturct from MySQL database. big Camel-Case Name Rule, JSON tag.
### big Camel-Case Name Rule
### JSON tag
## gui support
![show](/image/gormt/ui_en.gif)
```
./gormt -g=true
```
## cmd support
![show](/image/gormt/out.gif)
```
./gormt -g=false
```
--------
## 1. Configure default configuration items through the current directory config.yml file
```
out_dir : "." # out dir
singular_table : false # Table name plural (big Camel-Case):gorm.SingularTable
url_tag : json # web url tag(json,db(https://github.com/google/go-querystring))
language : # language(English,中 文)
db_tag : gorm # DB tag(gorm,db)
singular_table : true # Table name plural (big Camel-Case):gorm.SingularTable
simple : false #simple output
is_out_sql : false # Whether to output sql
is_out_func : true # Whether to output function
is_json_tag : true # Whether to mark JSON or not
is_url_tag : true # Whether to mark web or not
is_foreign_key : true # Whether to mark foreign key or not
is_gui : false # Whether to operate on gui
mysql_info :
host : "127.0.0.1"
@@ -50,12 +63,14 @@ Flags:
-d, --database string 数据库名
-f, --foreign 是否导出外键关联
-F, --fun 是否导出函数
-g, --gui 是否ui显示模式
-h, --help help for main
-H, --host string 数据库地址.(注意-H为大写)
-o, --outdir string 输出目录
-p, --password string 密码.
--port int 端口号 (default 3306)
-s, --singular 是否禁用表名复数
-l, --url string url标签(json,url)
-u, --user string 用户名.
```

View File

@@ -9,28 +9,45 @@
#### mysql数据库转 struct 工具,可以将mysql数据库自动生成golang sturct结构带大驼峰命名规则。带json标签
![show](/image/gormt/out.gif)
[English](README.md)
## 交互界面模式
![show](/image/gormt/ui_cn.gif)
```
./gormt -g=true
```
## 命令行模式
![show](/image/gormt/out.gif)
```
./gormt -g=false
```
--------
## 1. 通过当前目录 config.yml 文件配置默认配置项
```
out_dir : "." # 输出目录
singular_table : false # 表名复数,是否大驼峰构建 参考:gorm.SingularTable
simple : false #简单输出
base:
is_dev : false
out_dir : ./model # 输出目录
url_tag : json # web url tag(json,db(https://github.com/google/go-querystring))
language : # 语言(English,中 文)
db_tag : gorm # 数据库标签(gorm,db)
singular_table : false # 单表模式:true:禁用表名复数,false:采用表明复数 参考:gorm.SingularTable
simple : false # 简单输出(默认gorm标签不输出)
is_out_sql : false # 是否输出 sql 原信息
is_out_func : true # 是否输出 快捷函数
is_json_tag : false #是否打json标记
is_foreign_key : true #是否导出外键关联
mysql_info :
host : "127.0.0.1"
is_url_tag : true # 是否打web标记
is_foreign_key : true # 是否导出外键关联
is_gui : false # 是否ui模式显示
mysql_info:
host : 127.0.0.1
port : 3306
username : "root"
password : "qwer"
database : "oauth_db"
username : root
password : qwer
database : oauth_db
```
## 2. 可以使用命令行工具更新配置项
@@ -56,12 +73,14 @@ Flags:
-d, --database string 数据库名
-f, --foreign 是否导出外键关联
-F, --fun 是否导出函数
-g, --gui 是否ui显示模式
-h, --help help for main
-H, --host string 数据库地址.(注意-H为大写)
-o, --outdir string 输出目录
-p, --password string 密码.
--port int 端口号 (default 3306)
-s, --singular 是否禁用表名复数
-l, --url string url标签(json,url)
-u, --user string 用户名.
```

View File

@@ -1,15 +1,20 @@
base:
is_dev : false
out_dir : ./model # 输出目录
singular_table : false # 单表模式:true:禁用表名复数,false:采用表明复数 参考:gorm.SingularTable
url_tag : json # web url tag(json,db(https://github.com/google/go-querystring))
language : # 语言(English,中 文)
db_tag : gorm # 数据库标签(gorm,db)
singular_table : true # 单表模式:true:禁用表名复数,false:采用表名复数 参考:gorm.SingularTable
simple : false # 简单输出(默认gorm标签不输出)
is_out_sql : false # 是否输出 sql 原信息
is_out_func : true # 是否输出 快捷函数
is_json_tag : true # 是否打json标记
is_url_tag : true # 是否打web标记
is_foreign_key : true # 是否导出外键关联
is_gui : false # 是否ui模式显示
mysql_info:
host : 127.0.0.1
port : 3306
username : root
password : qwer
database : matrix
database : oauth_db

View File

@@ -19,6 +19,8 @@ var outDir string
var singularTable bool
var foreignKey bool
var funcKey bool
var ui bool
var urlTag string
var rootCmd = &cobra.Command{
Use: "main",
@@ -55,7 +57,7 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&outDir, "outdir", "o", "", "输出目录")
rootCmd.MarkFlagRequired("outdir")
rootCmd.PersistentFlags().BoolVarP(&singularTable, "singular", "s", false, "是否禁用表名复数")
rootCmd.PersistentFlags().BoolVarP(&singularTable, "singular", "s", true, "是否禁用表名复数")
rootCmd.MarkFlagRequired("singular")
rootCmd.PersistentFlags().BoolVarP(&foreignKey, "foreign", "f", false, "是否导出外键关联")
@@ -64,6 +66,12 @@ func init() {
rootCmd.PersistentFlags().BoolVarP(&funcKey, "fun", "F", false, "是否导出函数")
rootCmd.MarkFlagRequired("func export")
rootCmd.PersistentFlags().BoolVarP(&ui, "gui", "g", false, "是否ui显示模式")
rootCmd.MarkFlagRequired("show on gui")
rootCmd.PersistentFlags().StringVarP(&urlTag, "url", "l", "", "url标签(json,url)")
rootCmd.MarkFlagRequired("url tag")
rootCmd.Flags().IntVar(&mysqlInfo.Port, "port", 3306, "端口号")
}
@@ -100,6 +108,9 @@ func MergeMysqlDbInfo() {
if len(mysqlInfo.Username) > 0 {
tmp.Username = mysqlInfo.Username
}
if len(urlTag) > 0 {
config.SetURLTag(urlTag)
}
config.SetMysqlDbInfo(&tmp)
@@ -118,4 +129,9 @@ func MergeMysqlDbInfo() {
if funcKey {
config.SetIsOutFunc(funcKey)
}
if ui {
config.SetIsGUI(ui)
}
}

View File

@@ -1,18 +1,26 @@
package config
import "fmt"
import (
"fmt"
"github.com/xxjwxc/public/tools"
)
// Config custom config struct
type Config struct {
CfgBase `yaml:"base"`
MySQLInfo MysqlDbInfo `yaml:"mysql_info"`
OutDir string `yaml:"out_dir"`
URLTag string `yaml:"url_tag"` // url tag
Language string `yaml:"language"` // language
DbTag string `yaml:"db_tag"` // 数据库标签gormt,db
Simple bool `yaml:"simple"`
IsJSONTag bool `yaml:"is_json_tag"`
IsWEBTag bool `yaml:"is_web_tag"`
SingularTable bool `yaml:"singular_table"`
IsForeignKey bool `yaml:"is_foreign_key"`
IsOutSQL bool `yaml:"is_out_sql"`
IsOutFunc bool `yaml:"is_out_func"`
IsGUI bool `yaml:"is_gui"` //
}
// MysqlDbInfo mysql database information. mysql 数据库信息
@@ -52,6 +60,10 @@ func SetOutDir(outDir string) {
// GetOutDir Get Output Directory.获取输出目录
func GetOutDir() string {
if len(_map.OutDir) == 0 {
_map.OutDir = "./model"
}
return _map.OutDir
}
@@ -70,9 +82,14 @@ func GetSimple() bool {
return _map.Simple
}
// GetIsJSONTag json tag.json标记
func GetIsJSONTag() bool {
return _map.IsJSONTag
// SetSimple simple output.简单输出
func SetSimple(b bool) {
_map.Simple = b
}
// GetIsWEBTag json tag.json标记
func GetIsWEBTag() bool {
return _map.IsWEBTag
}
// GetIsForeignKey if is foreign key
@@ -85,6 +102,11 @@ func SetForeignKey(b bool) {
_map.IsForeignKey = b
}
// SetIsOutSQL if is output sql .
func SetIsOutSQL(b bool) {
_map.IsOutSQL = b
}
// GetIsOutSQL if is output sql .
func GetIsOutSQL() bool {
return _map.IsOutSQL
@@ -99,3 +121,59 @@ func GetIsOutFunc() bool {
func SetIsOutFunc(b bool) {
_map.IsOutFunc = b
}
// GetIsGUI if is gui show .
func GetIsGUI() bool {
return _map.IsGUI
}
// SetIsGUI if is gui show .
func SetIsGUI(b bool) {
_map.IsGUI = b
}
// GetURLTag get url tag.
func GetURLTag() string {
if _map.URLTag != "json" && _map.URLTag != "url" {
_map.URLTag = "json"
}
return _map.URLTag
}
// SetURLTag set url tag.
func SetURLTag(s string) {
_map.URLTag = s
}
// GetLG get language tag.
func GetLG() string {
if _map.Language != "English" && _map.Language != "中 文" {
if tools.GetLocalSystemLang(true) == "en" {
_map.Language = "English"
} else {
_map.Language = "中 文"
}
}
return _map.Language
}
// SetLG set url tag.
func SetLG(s string) {
_map.Language = s
}
// GetDBTag get database tag.
func GetDBTag() string {
if _map.DbTag != "gorm" && _map.DbTag != "db" {
_map.DbTag = "gorm"
}
return _map.DbTag
}
// SetDBTag get database tag.
func SetDBTag(s string) {
_map.DbTag = s
}

View File

@@ -6,16 +6,16 @@ import (
"github.com/xxjwxc/public/dev"
"github.com/xxjwxc/public/tools"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
)
// CfgBase base config struct
type CfgBase struct {
SerialNumber string `json:"serial_number" yaml:"serial_number"` // version.版本号
ServiceName string `json:"service_name" yaml:"service_name"` // service name .service名字
ServiceDisplayname string `json:"service_displayname" yaml:"service_displayname"` // display name .显示名
SerciceDesc string `json:"sercice_desc" yaml:"sercice_desc"` // sercice desc .service描述
IsDev bool `json:"is_dev" yaml:"is_dev"` // Is it a development version?是否是开发版本
// SerialNumber string `json:"serial_number" yaml:"serial_number"` // version.版本号
// ServiceName string `json:"service_name" yaml:"service_name"` // service name .service名字
// ServiceDisplayname string `json:"service_displayname" yaml:"service_displayname"` // display name .显示名
// SerciceDesc string `json:"sercice_desc" yaml:"sercice_desc"` // sercice desc .service描述
IsDev bool `json:"is_dev" yaml:"is_dev"` // Is it a development version?是否是开发版本
}
var _map = Config{}
@@ -49,9 +49,32 @@ func InitFile(filename string) error {
}
// GetServiceConfig Get service configuration information
func GetServiceConfig() (name, displayName, desc string) {
name = _map.ServiceName
displayName = _map.ServiceDisplayname
desc = _map.SerciceDesc
return
// func GetServiceConfig() (name, displayName, desc string) {
// name = _map.ServiceName
// displayName = _map.ServiceDisplayname
// desc = _map.SerciceDesc
// return
// }
// GetIsDev is is dev
func GetIsDev() bool {
return _map.IsDev
}
// SetIsDev is is dev
func SetIsDev(b bool) {
_map.IsDev = b
}
// SaveToFile save config info to file
func SaveToFile() error {
d, err := yaml.Marshal(_map)
if err != nil {
return err
}
tools.WriteFile(tools.GetModelPath()+"/config.yml", []string{
string(d),
}, true)
return nil
}

View File

@@ -13,7 +13,7 @@ service_displayname : #服务显示名
sercice_desc : #服务描述
is_dev : false # 是否开发者模式
out_dir : ./db # 输出目录
singular_table : false # 单表模式:true:禁用表名复数,false:采用表明复数 参考:gorm.SingularTable
singular_table : true # 单表模式:true:禁用表名复数,false:采用表明复数 参考:gorm.SingularTable
simple : true #简单输出
isJsonTag : true #是否打json标记
mysql_info:

7
data/dlg/cmd_darwin.go Normal file
View File

@@ -0,0 +1,7 @@
package dlg
import "os/exec"
func openURL(url string) {
exec.Command(`open`, url).Start()
}

7
data/dlg/cmd_linux.go Normal file
View File

@@ -0,0 +1,7 @@
package dlg
import "os/exec"
func openURL(url string) {
exec.Command(`xdg-open`, url).Start()
}

7
data/dlg/cmd_windows.go Normal file
View File

@@ -0,0 +1,7 @@
package dlg
import "os/exec"
func openURL(url string) {
exec.Command(`cmd`, `/c`, `start`, url).Start() // 有GUI调用
}

98
data/dlg/common.go Normal file
View File

@@ -0,0 +1,98 @@
package dlg
import (
"os/exec"
"github.com/jroimartin/gocui"
"github.com/xxjwxc/gormt/data/view/model"
"github.com/xxjwxc/gormt/data/view/model/genmysql"
"github.com/xxjwxc/gormt/data/config"
"github.com/xxjwxc/public/tools"
)
func division(a int, b float32) int {
r := float32(a) / b
return (int)(r)
}
func (dlg *menuDetails) nextButton(g *gocui.Gui, v *gocui.View) error {
dlg.btnList[dlg.active].UnFocus()
dlg.active = (dlg.active + 1) % len(dlg.btnList)
menuFocusButton(g)
return nil
}
func menuFocusButton(g *gocui.Gui) {
setlog(g, SLocalize(btnLogArr[menuDlg.active]))
menuDlg.btnList[menuDlg.active].Focus()
}
func (dlg *menuDetails) prevButton(g *gocui.Gui, v *gocui.View) error {
dlg.btnList[dlg.active].UnFocus()
if dlg.active == 0 {
dlg.active = len(dlg.btnList)
}
dlg.active--
menuFocusButton(g)
return nil
}
func (dlg *menuDetails) Draw() {
for _, b := range dlg.btnList {
b.Draw()
}
}
// OnDestroy destroy windows
func OnDestroy(g *gocui.Gui, v *gocui.View) error {
return gocui.ErrQuit
}
func setCurrentViewOnTop(g *gocui.Gui, name string) (*gocui.View, error) {
if _, err := g.SetCurrentView(name); err != nil {
return nil, err
}
return g.SetViewOnTop(name)
}
func requireValidator(value string) bool {
if value == "" {
return false
}
return true
}
func getBool(bstr string) bool {
if bstr == "true" || bstr == " 是" {
return true
}
return false
}
func generate(g *gocui.Gui, v *gocui.View) {
modeldb := genmysql.GetMysqlModel()
pkg := modeldb.GenModel()
// just for test
// out, _ := json.Marshal(pkg)
// tools.WriteFile("test.txt", []string{string(out)}, true)
list, mo := model.Generate(pkg)
addlog(g, "\n \033[32;7m 开 始 : begin \033[0m\n")
for _, v := range list {
path := config.GetOutDir() + "/" + v.FileName
tools.WriteFile(path, []string{v.FileCtx}, true)
addlog(g, " formatting differs from goimport's:")
cmd, _ := exec.Command("goimports", "-l", "-w", path).Output()
addlog(g, " "+string(cmd))
}
addlog(g, "\033[32;7m 所 有 已 完 成 : ALL completed!! \033[0m\n")
// build item
gPkg = mo.GetPackage()
buildList(g, v)
}

407
data/dlg/cui.go Normal file
View File

@@ -0,0 +1,407 @@
package dlg
import (
"fmt"
"log"
"strconv"
"strings"
"github.com/xxjwxc/public/tools"
"github.com/xxjwxc/gormt/data/config"
"github.com/jroimartin/gocui"
"github.com/xxjwxc/public/myclipboard"
"github.com/xxjwxc/public/mycui"
)
func nextView(g *gocui.Gui, v *gocui.View) error {
nextIndex := (mainIndex + 1) % len(mainViewArr)
name := mainViewArr[nextIndex]
if _, err := g.SetCurrentView(name); err != nil { // 设置选中
return err
}
g.SelFgColor = gocui.ColorGreen // 设置边框颜色
g.FgColor = gocui.ColorWhite
switch name {
case _menuDefine:
//g.Cursor = false // 光标
// g.FgColor = gocui.ColorGreen
menuDlg.btnList[menuDlg.active].Focus()
case _listDefine:
//g.Cursor = false
menuDlg.btnList[menuDlg.active].UnFocus()
case _viewDefine:
//g.Cursor = true
menuDlg.btnList[menuDlg.active].UnFocus()
}
mainIndex = nextIndex
return nil
}
func mainLayout(g *gocui.Gui) error {
maxX, maxY := g.Size()
if v, err := g.SetView("main_title", maxX/2-16, -1, maxX/2+16, 1); err != nil {
if err != gocui.ErrUnknownView {
return err
}
v.Highlight = true
v.SelFgColor = gocui.ColorGreen | gocui.AttrUnderline
fmt.Fprintln(v, "https://github.com/xxjwxc/gormt")
}
if v, err := g.SetView(_menuDefine, 0, 1, division(maxX, uiPart[0])-1, division(maxY, uiPart[1])-1); err != nil {
if err != gocui.ErrUnknownView {
return err
}
v.Title = SLocalize(_menuDefine)
// v.Editable = true // 是否可以编辑
v.Wrap = true
v.Autoscroll = true
// g.FgColor = gocui.ColorGreen
}
if v, err := g.SetView(_listDefine, 0, division(maxY, uiPart[1]), division(maxX, uiPart[0])-1, maxY-1); err != nil {
if err != gocui.ErrUnknownView {
return err
}
v.Title = SLocalize(_listDefine)
// v.Wrap = true
// v.Autoscroll = true
v.Highlight = true
v.SelBgColor = gocui.ColorGreen
v.SelFgColor = gocui.ColorBlack
// if _, err := g.SetCurrentView(_menuDefine); err != nil {
// return err
// }
}
if v, err := g.SetView(_viewDefine, division(maxX, uiPart[0]), 1, maxX-1, maxY-3); err != nil {
if err != gocui.ErrUnknownView {
return err
}
v.Title = SLocalize(_viewDefine)
v.Wrap = true
v.Autoscroll = true
v.Editable = true
}
nemuLayOut(g) // menuLayOut
return nil
}
func nemuLayOut(g *gocui.Gui) {
menuDlg = &menuDetails{}
menuDlg.btnList = append(menuDlg.btnList,
mycui.NewButton(g, _run, SLocalize(_run), 0, 2, 3).SetTextColor(gocui.ColorRed|gocui.AttrReverse, gocui.ColorWhite).
AddHandler(gocui.KeyArrowUp, menuDlg.prevButton).AddHandler(gocui.KeyArrowDown, menuDlg.nextButton).
AddHandler(gocui.KeyEnter, enterRun).AddHandler(gocui.MouseLeft, enterRun))
menuDlg.btnList = append(menuDlg.btnList,
mycui.NewButton(g, _set, SLocalize(_set), 0, 4, 3).
AddHandler(gocui.KeyArrowUp, menuDlg.prevButton).AddHandler(gocui.KeyArrowDown, menuDlg.nextButton).
AddHandler(gocui.KeyEnter, enterSet).AddHandler(gocui.MouseLeft, enterSet))
maxX, maxY := g.Size() // division(maxY, uiPart[1])
clipboardBtn = mycui.NewButton(g, _clipboardBtn, SLocalize(_clipboardBtn), division(maxX, uiPart[0])+2, maxY-3, 5).
AddHandler(gocui.KeyEnter, enterClipboard).AddHandler(gocui.MouseLeft, enterClipboard)
clipboardBtn.Draw()
menuDlg.Draw()
menuFocusButton(g)
}
func keybindings(g *gocui.Gui) {
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, OnDestroy); err != nil { // 退出事件
log.Panicln(err)
}
if err := g.SetKeybinding("", gocui.KeyTab, gocui.ModNone, nextView); err != nil { // tab next事件
log.Panicln(err)
}
if err := g.SetKeybinding("", gocui.KeyEsc, gocui.ModNone, buttonCancel); err != nil {
log.Panicln(err)
}
if err := g.SetKeybinding("", gocui.KeyCtrlQ, gocui.ModNone, buttonCancel); err != nil {
log.Panicln(err)
}
if err := g.SetKeybinding("main_title", gocui.MouseLeft, gocui.ModNone, about); err != nil {
log.Panicln(err)
}
if err := g.SetKeybinding(_listDefine, gocui.KeyArrowDown, gocui.ModNone, listDown); err != nil {
log.Panicln(err)
}
if err := g.SetKeybinding(_listDefine, gocui.KeyArrowUp, gocui.ModNone, listUp); err != nil {
log.Panicln(err)
}
if err := g.SetKeybinding(_listDefine, gocui.KeyEnter, gocui.ModNone, showStruct); err != nil {
log.Panicln(err)
}
if err := g.SetKeybinding(_listDefine, gocui.MouseLeft, gocui.ModNone, showStruct); err != nil {
log.Panicln(err)
}
}
///////////////////signal slot ///////////
func about(g *gocui.Gui, v *gocui.View) error {
openURL("https://github.com/xxjwxc/gormt")
return nil
}
func setlog(g *gocui.Gui, str string) error {
logView, err := g.View(_viewDefine)
if err == nil {
logView.Clear()
fmt.Fprintln(logView, str)
}
return err
}
func addlog(g *gocui.Gui, str string) error {
logView, err := g.View(_viewDefine)
if err == nil {
fmt.Fprintln(logView, str)
}
return err
}
func enterClipboard(g *gocui.Gui, v *gocui.View) error {
myclipboard.Set(copyInfo)
maxX, _ := g.Size()
modal := mycui.NewModal(g, division(maxX, uiPart[0])+5, 10, division(maxX, uiPart[0])+35).
SetTextColor(gocui.ColorRed).SetText("copy success \n 已 复 制 到 剪 切 板 ")
modal.Mouse = true
// modal.SetBgColor(gocui.ColorRed)
_handle := func(g *gocui.Gui, v *gocui.View) error {
modal.Close()
return nil
}
modal.AddButton("ok", "OK", gocui.KeyEnter, _handle).AddHandler(gocui.MouseLeft, _handle)
modal.Draw()
return nil
}
func enterRun(g *gocui.Gui, v *gocui.View) error {
setlog(g, "run .... ing")
generate(g, v)
return nil
}
func enterSet(g *gocui.Gui, v *gocui.View) error {
maxX, _ := g.Size()
setlog(g, "")
// new form
form = mycui.NewForm(g, "set_ui", "Sign Up", division(maxX, uiPart[0])+2, 2, 0, 0)
// add input field
form.AddInputField("out_dir", SLocalize("out_dir"), formPart[0], formPart[1]).SetText(config.GetOutDir()).
AddValidate("required input", requireValidator)
form.AddInputField("db_host", SLocalize("db_host"), formPart[0], formPart[1]).SetText(config.GetMysqlDbInfo().Host).
AddValidate("required input", requireValidator)
form.AddInputField("db_port", SLocalize("db_port"), formPart[0], formPart[1]).SetText(tools.AsString(config.GetMysqlDbInfo().Port)).
AddValidate("required input", requireValidator)
form.AddInputField("db_usename", SLocalize("db_usename"), formPart[0], formPart[1]).SetText(config.GetMysqlDbInfo().Username).
AddValidate("required input", requireValidator)
form.AddInputField("db_pwd", SLocalize("db_pwd"), formPart[0], formPart[1]).SetText(config.GetMysqlDbInfo().Password).
SetMask().SetMaskKeybinding(gocui.KeyCtrlA).
AddValidate("required input", requireValidator)
form.AddInputField("db_name", SLocalize("db_name"), formPart[0], formPart[1]).SetText(config.GetMysqlDbInfo().Database).
AddValidate("required input", requireValidator)
// add select
form.AddSelect("is_dev", SLocalize("is_dev"), formPart[0], formPart[2]).
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetIsDev())))
form.AddSelect("is_simple", SLocalize("is_simple"), formPart[0], formPart[2]).
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetSimple())))
form.AddSelect("is_singular", SLocalize("is_singular"), formPart[0], formPart[2]).
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetSingularTable())))
form.AddSelect("is_out_sql", SLocalize("is_out_sql"), formPart[0], formPart[2]).
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetIsOutSQL())))
form.AddSelect("is_out_func", SLocalize("is_out_func"), formPart[0], formPart[2]).
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetIsOutFunc())))
form.AddSelect("is_foreign_key", SLocalize("is_foreign_key"), formPart[0], formPart[2]).
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetIsForeignKey())))
form.AddSelect("is_gui", SLocalize("is_gui"), formPart[0], formPart[2]).
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetIsGUI())))
form.AddSelect("url_tag", SLocalize("url_tag"), formPart[0], formPart[2]).
AddOptions("json", "url").SetSelected(tools.AsString(config.GetURLTag()))
form.AddSelect("db_tag", SLocalize("db_tag"), formPart[0], formPart[2]).
AddOptions("gorm", "db").SetSelected(config.GetDBTag())
form.AddSelect("language", SLocalize("language"), formPart[0], formPart[2]).
AddOptions("English", "中 文").SetSelected(config.GetLG())
// add button
form.AddButton("save", SLocalize("save"), buttonSave).AddHandler(gocui.MouseLeft, buttonSave)
form.AddButton("cancel", SLocalize("cancel"), buttonCancel).AddHandler(gocui.MouseLeft, buttonCancel)
form.AddButton("about", SLocalize("about"), about).AddHandler(gocui.MouseLeft, about)
form.Draw()
return nil
}
func buttonCancel(g *gocui.Gui, v *gocui.View) error {
menuFocusButton(g)
if form != nil {
err := form.Close(g, nil)
form = nil
return err
}
return nil
}
func buttonSave(g *gocui.Gui, v *gocui.View) error {
maxX, _ := g.Size()
mp := form.GetFieldTexts()
config.SetOutDir(mp["out_dir"])
var dbInfo config.MysqlDbInfo
dbInfo.Host = mp["db_host"]
port, err := strconv.Atoi(mp["db_port"])
if err != nil {
modal := mycui.NewModal(g, division(maxX, uiPart[0])+5, 10, division(maxX, uiPart[0])+35).SetTextColor(gocui.ColorRed).SetText("port error")
_handle := func(g *gocui.Gui, v *gocui.View) error {
modal.Close()
form.SetCurrentItem(form.GetCurrentItem())
return nil
}
// modal.SetBgColor(gocui.ColorRed)
modal.AddButton("ok", "OK", gocui.KeyEnter, _handle).AddHandler(gocui.MouseLeft, _handle)
modal.Draw()
return nil
}
dbInfo.Port = port
dbInfo.Username = mp["db_usename"]
dbInfo.Password = mp["db_pwd"]
dbInfo.Database = mp["db_name"]
config.SetMysqlDbInfo(&dbInfo)
mp = form.GetSelectedOpts()
config.SetIsDev(getBool(mp["is_dev"]))
config.SetSimple(getBool(mp["is_simple"]))
config.SetSingularTable(getBool(mp["is_singular"]))
config.SetIsOutSQL(getBool(mp["is_out_sql"]))
config.SetIsOutFunc(getBool(mp["is_out_func"]))
config.SetForeignKey(getBool(mp["is_foreign_key"]))
config.SetIsGUI(getBool(mp["is_gui"]))
config.SetURLTag(mp["url_tag"])
config.SetDBTag(mp["db_tag"])
config.SetLG(mp["language"])
config.SaveToFile()
modal := mycui.NewModal(g, division(maxX, uiPart[0])+5, 10, division(maxX, uiPart[0])+35).SetText("save success")
_handle := func(g *gocui.Gui, v *gocui.View) error {
modal.Close()
buttonCancel(g, v)
return nil
}
modal.AddButton("ok", "OK", gocui.KeyEnter, _handle).AddHandler(gocui.MouseLeft, _handle)
modal.Draw()
return nil
}
func buildList(g *gocui.Gui, v *gocui.View) error {
listView, err := g.View(_listDefine)
if err != nil {
panic(err)
}
listView.Clear()
for _, info := range gPkg.Structs {
fmt.Fprintln(listView, info.Name)
}
return nil
}
func showStruct(g *gocui.Gui, v *gocui.View) error {
var l string
var err error
_, cy := v.Cursor()
if l, err = v.Line(cy); err != nil {
l = ""
}
var out, out1 []string
for _, v := range gPkg.Structs {
if v.Name == l {
out = v.GeneratesColor()
out1 = v.Generates()
break
}
}
setlog(g, "\n\n\n")
for _, v := range out {
addlog(g, v)
}
copyInfo = strings.Join(out1, "\n")
return nil
}
func listDown(g *gocui.Gui, v *gocui.View) error {
if v != nil {
cx, cy := v.Cursor()
if cy < len(gPkg.Structs)-1 {
if err := v.SetCursor(cx, cy+1); err != nil {
ox, oy := v.Origin()
if err := v.SetOrigin(ox, oy+1); err != nil {
return err
}
}
}
}
return nil
}
func listUp(g *gocui.Gui, v *gocui.View) error {
if v != nil {
ox, oy := v.Origin()
cx, cy := v.Cursor()
if err := v.SetCursor(cx, cy-1); err != nil && oy > 0 {
if err := v.SetOrigin(ox, oy-1); err != nil {
return err
}
}
}
return nil
}
///////////////////////////////////////////
// OnInitDialog init main loop
func OnInitDialog() {
g, err := gocui.NewGui(gocui.OutputNormal)
if err != nil {
log.Panicln(err)
}
defer g.Close()
g.Cursor = false // 光标
g.Mouse = true
g.Highlight = true
g.SelFgColor = gocui.ColorGreen // 设置边框颜色
mainLayout(g)
//g.SetManagerFunc(mainLayout) // 主布局
keybindings(g)
if err := g.MainLoop(); err != nil && err != gocui.ErrQuit { // 主循环
log.Panicln(err)
}
}

42
data/dlg/def.go Normal file
View File

@@ -0,0 +1,42 @@
package dlg
import (
"github.com/xxjwxc/gormt/data/view/genstruct"
"github.com/xxjwxc/public/mycui"
)
const (
_menuDefine = "menu"
_listDefine = "list"
_viewDefine = "view"
_run = "run"
_set = "set"
_clipboardBtn = "clipboardBtn"
)
var (
uiPart = []float32{4, 5} // x,y 对应列表
mainViewArr = []string{_menuDefine, _listDefine, _viewDefine} // 主菜单列表
mainIndex = 0
btnLogArr = []string{"log_run", "log_set"} // 主菜单列表
formPart = []int{14, 28, 10}
)
// menu 内容
type menuDetails struct {
active int
btnList []*mycui.Button
}
type listDetails struct {
active int
btnList []*mycui.Button
}
var clipboardBtn *mycui.Button
var copyInfo string
var menuDlg *menuDetails
var form *mycui.Form
var gPkg genstruct.GenPackage

214
data/dlg/i18n.go Normal file
View File

@@ -0,0 +1,214 @@
package dlg
import (
"github.com/nicksnyder/go-i18n/v2/i18n"
"github.com/xxjwxc/gormt/data/config"
"github.com/xxjwxc/public/myi18n"
"golang.org/x/text/language"
)
/*
Internationalization 国际化
*/
func init() {
addChinese()
addEnglish()
myi18n.SetLocalLG(getLG()) // default
}
func getLG() string {
tag := config.GetLG()
if tag == "English" {
return "en"
}
return "zh"
}
// SLocalize 获取值
func SLocalize(ID string) string {
return myi18n.Get(ID)
}
func addChinese() error {
return myi18n.AddMessages(language.Chinese, &i18n.Message{
ID: "menu",
Other: "菜单",
}, &i18n.Message{
ID: "list",
Other: "列表",
}, &i18n.Message{
ID: "view",
Other: "视图",
}, &i18n.Message{
ID: "run",
Other: "执 行 ⏯ ",
}, &i18n.Message{
ID: "set",
Other: "设 置 🛠 ",
}, &i18n.Message{
ID: "clipboardBtn",
Other: "复 制 到 剪 切 板 ",
}, &i18n.Message{
ID: "out_dir",
Other: " 输 出 目 录 :",
}, &i18n.Message{
ID: "db_host",
Other: " 数 据 库 地 址 :",
}, &i18n.Message{
ID: "db_port",
Other: " 数 据 库 端 口 :",
}, &i18n.Message{
ID: "db_usename",
Other: " 数 据 库 用 户 名 :",
}, &i18n.Message{
ID: "db_pwd",
Other: " 数 据 库 密 码:",
}, &i18n.Message{
ID: "db_name",
Other: " 数 据 库 名 字 :",
}, &i18n.Message{
ID: "is_dev",
Other: " 开 发 模 式:",
}, &i18n.Message{
ID: "is_singular",
Other: " 单 表 模 式 :",
}, &i18n.Message{
ID: "is_simple",
Other: " 简 单 输 出 :",
}, &i18n.Message{
ID: "is_out_sql",
Other: " 输 出 sql 原 :",
}, &i18n.Message{
ID: "is_out_func",
Other: " 输 出 快 捷 函 数 :",
}, &i18n.Message{
ID: "is_foreign_key",
Other: " 导 出 外 键 :",
}, &i18n.Message{
ID: "is_gui",
Other: " 界 面 模 式 :",
}, &i18n.Message{
ID: "url_tag",
Other: " web 标 签:",
}, &i18n.Message{
ID: "db_tag",
Other: " 数 据 库 标 签 :",
}, &i18n.Message{
ID: "language",
Other: " 语 言 :",
}, &i18n.Message{
ID: "true",
Other: " 是",
}, &i18n.Message{
ID: "false",
Other: " 否",
}, &i18n.Message{
ID: "save",
Other: " 保 存 ",
}, &i18n.Message{
ID: "cancel",
Other: " 取 消 ",
}, &i18n.Message{
ID: "about",
Other: " 关 于 作 者",
}, &i18n.Message{
ID: "log_run",
Other: " Enter : 执 行 \n ↑ ↓: 本 视 图 选 择 \n Tab : 多 视 图 切 换 \n Ctrl+C : 退 出 应 用 \n Ctrl+Q : 退 出 对 话 框 \n 支 持 鼠 标 操 作 方 式 \n \n \033[33;7m 输 入 Enter 直 接 执 行 \033[0m\n ",
}, &i18n.Message{
ID: "log_set",
Other: " Enter : 执 行 \n ↑ ↓: 本 视 图 选 择 \n Tab : 多 视 图 切 换\n Ctrl+C : 退 出 应 用 \n Ctrl+Q : 退 出 对 话 框 \n 支 持 鼠 标 操 作 方 式 \n \n \033[33;7m 输 入 Enter 打 开 设 置 窗 口 \033[0m\n ",
})
}
func addEnglish() error {
return myi18n.AddMessages(language.English, &i18n.Message{
ID: "menu",
Other: "Menu",
}, &i18n.Message{
ID: "list",
Other: "List",
}, &i18n.Message{
ID: "view",
Other: "View",
}, &i18n.Message{
ID: "run",
Other: "Run ⏯ ",
}, &i18n.Message{
ID: "set",
Other: "Set 🛠 ",
}, &i18n.Message{
ID: "clipboardBtn",
Other: "Copy to clipboard",
}, &i18n.Message{
ID: "out_dir",
Other: "out dir:",
}, &i18n.Message{
ID: "db_host",
Other: "db host:",
}, &i18n.Message{
ID: "db_port",
Other: "db port:",
}, &i18n.Message{
ID: "db_usename",
Other: "db username:",
}, &i18n.Message{
ID: "db_pwd",
Other: "db password:",
}, &i18n.Message{
ID: "db_name",
Other: "db name:",
}, &i18n.Message{
ID: "is_dev",
Other: "is dev:",
}, &i18n.Message{
ID: "is_simple",
Other: "is simple :",
}, &i18n.Message{
ID: "is_singular",
Other: "is singular :",
}, &i18n.Message{
ID: "is_out_sql",
Other: "is out sql :",
}, &i18n.Message{
ID: "is_out_func",
Other: "is out func :",
}, &i18n.Message{
ID: "is_foreign_key",
Other: "is foreign key:",
}, &i18n.Message{
ID: "is_gui",
Other: "is show gui:",
}, &i18n.Message{
ID: "url_tag",
Other: "url tag:",
}, &i18n.Message{
ID: "db_tag",
Other: "db tag:",
}, &i18n.Message{
ID: "language",
Other: "Language:",
}, &i18n.Message{
ID: "true",
Other: "true",
}, &i18n.Message{
ID: "false",
Other: "false",
}, &i18n.Message{
ID: "save",
Other: "Save",
}, &i18n.Message{
ID: "cancel",
Other: "Cancel",
}, &i18n.Message{
ID: "about",
Other: "About",
}, &i18n.Message{
ID: "log_run",
Other: " Enter : run \n ↑ ↓: Selection of this view \n Tab : Multi view switching \n Ctrl+C : quit; \n Ctrl+Q : backup \n Mouse operation supported \n \n \033[33;7m Enter to execute \033[0m",
}, &i18n.Message{
ID: "log_set",
Other: " Enter : run \n ↑ ↓: Selection of this view \n Tab : Multi view switching \n Ctrl+C : quit \n Ctrl+Q : backup \n Mouse operation supported \n \n \033[33;7m Enter enter to open the settings window \033[0m",
})
}

6
data/dlg/mycui.go Normal file
View File

@@ -0,0 +1,6 @@
package dlg
// WinMain windows main loop
func WinMain() {
OnInitDialog()
}

View File

@@ -60,6 +60,33 @@ func (e *GenElement) Generate() string {
return p.Generates()[0]
}
// GenerateColor Get the result data.获取结果数据
func (e *GenElement) GenerateColor() string {
tag := ""
if e.Tags != nil {
var ks []string
for k := range e.Tags {
ks = append(ks, k)
}
sort.Strings(ks)
var tags []string
for _, v := range ks {
tags = append(tags, fmt.Sprintf(`%v:"%v"`, v, strings.Join(e.Tags[v], ";")))
}
tag = fmt.Sprintf("`%v`", strings.Join(tags, " "))
}
var p generate.PrintAtom
if len(e.Notes) > 0 {
p.Add(e.Name, "\033[32;1m "+e.Type+" \033[0m", "\033[31;1m "+tag+" \033[0m", "\033[32;1m // "+e.Notes+" \033[0m")
} else {
p.Add(e.Name, "\033[32;1m "+e.Type+" \033[0m", "\033[31;1m "+tag+" \033[0m")
}
return p.Generates()[0]
}
//////////////////////////////////////////////////////////////////////////////
// struct
//////////////////////////////////////////////////////////////////////////////
@@ -108,14 +135,41 @@ func (s *GenStruct) Generates() []string {
}
p.Add(s.Notes)
p.Add("type", s.Name, "struct {")
mp := make(map[string]bool, len(s.Em))
for _, v := range s.Em {
p.Add(v.Generate())
if !mp[v.Name] {
mp[v.Name] = true
p.Add(v.Generate())
}
}
p.Add("}")
return p.Generates()
}
// \033[3%d;%dm -%d;%d-colors!\033[0m\n
// GeneratesColor Get the result data on color.获取结果数据 带颜色
func (s *GenStruct) GeneratesColor() []string {
var p generate.PrintAtom
if config.GetIsOutSQL() {
p.Add("\033[32;1m /******sql******\033[0m")
p.Add(s.SQLBuildStr)
p.Add("\033[32;1m ******sql******/ \033[0m")
}
p.Add("\033[32;1m " + s.Notes + " \033[0m")
p.Add("\033[34;1m type \033[0m", s.Name, "\033[34;1m struct \033[0m {")
mp := make(map[string]bool, len(s.Em))
for _, v := range s.Em {
if !mp[v.Name] {
mp[v.Name] = true
p.Add(" \t\t" + v.GenerateColor())
}
}
p.Add(" }")
return p.Generates()
}
//////////////////////////////////////////////////////////////////////////////
// package
//////////////////////////////////////////////////////////////////////////////

View File

@@ -1,12 +0,0 @@
package gtools
import (
"github.com/xxjwxc/gormt/data/view/model"
"github.com/xxjwxc/gormt/data/view/model/genmysql"
)
// GetMysqlModel get model interface. 获取model接口
func GetMysqlModel() model.IModel {
//now just support mysql
return &genmysql.MySQLModel
}

View File

@@ -4,28 +4,36 @@ import (
"fmt"
"os/exec"
"github.com/xxjwxc/gormt/data/dlg"
"github.com/xxjwxc/gormt/data/view/model"
"github.com/xxjwxc/gormt/data/config"
"github.com/xxjwxc/gormt/data/view/model/genmysql"
"github.com/xxjwxc/public/tools"
)
// Execute exe the cmd
func Execute() {
if config.GetIsGUI() {
dlg.WinMain()
} else {
showCmd()
}
}
func showCmd() {
// var tt oauth_db.UserInfoTbl
// tt.Nickname = "ticket_001"
// orm.Where("nickname = ?", "ticket_001").Find(&tt)
// fmt.Println(tt)
modeldb := GetMysqlModel()
modeldb := genmysql.GetMysqlModel()
pkg := modeldb.GenModel()
// just for test
// out, _ := json.Marshal(pkg)
// tools.WriteFile("test.txt", []string{string(out)}, true)
list := model.Generate(pkg)
list, _ := model.Generate(pkg)
for _, v := range list {
path := config.GetOutDir() + "/" + v.FileName

View File

@@ -15,8 +15,8 @@ import (
// getCamelName Big Hump or Capital Letter.大驼峰或者首字母大写
func getCamelName(name string) string {
if config.GetSingularTable() { // If the table name plural is globally disabled.如果全局禁用表名复数
return titleCase(name)
if !config.GetSingularTable() { // If the table name plural is globally disabled.如果全局禁用表名复数
return mybigcamel.Marshal(strings.TrimSuffix(name, "s"))
}
return mybigcamel.Marshal(name)

View File

@@ -1,8 +1,8 @@
package model
const (
_tagGorm = "gorm"
_tagJSON = "json"
// _tagGorm = "gorm"
// _tagJSON = "json"
)
// ColumusKey Columus type elem. 类型枚举

View File

@@ -3,13 +3,18 @@ package genmysql
import (
"strings"
"github.com/xxjwxc/gormt/data/config"
"github.com/xxjwxc/gormt/data/view/model"
)
// filterModel filter.过滤 gorm.Model
func filterModel(list *[]genColumns) bool {
var _temp []genColumns
if config.GetDBTag() != "gorm" {
return false
}
var _temp []genColumns
num := 0
for _, v := range *list {
if strings.EqualFold(v.Field, "id") ||
@@ -41,3 +46,9 @@ func fixForeignKey(list []genForeignKey, columuName string, result *[]model.Fore
}
}
}
// GetMysqlModel get model interface. 获取model接口
func GetMysqlModel() model.IModel {
//now just support mysql
return &MySQLModel
}

View File

@@ -169,7 +169,9 @@ func getTables(orm *mysqldb.MySqlDB) map[string]string {
rows, err := orm.Raw("show tables").Rows()
if err != nil {
fmt.Println(err)
if !config.GetIsGUI() {
fmt.Println(err)
}
return tbDesc
}
@@ -184,7 +186,9 @@ func getTables(orm *mysqldb.MySqlDB) map[string]string {
// Get table annotations.获取表注释
rows1, err := orm.Raw("SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE table_schema= '" + config.GetMysqlDbInfo().Database + "'").Rows()
if err != nil {
fmt.Println(err)
if !config.GetIsGUI() {
fmt.Println(err)
}
return tbDesc
}

View File

@@ -17,11 +17,12 @@ import (
type _Model struct {
info DBInfo
pkg *genstruct.GenPackage
}
// Generate build code string.生成代码
func Generate(info DBInfo) (out []GenOutInfo) {
m := _Model{
func Generate(info DBInfo) (out []GenOutInfo, m _Model) {
m = _Model{
info: info,
}
@@ -40,23 +41,36 @@ func Generate(info DBInfo) (out []GenOutInfo) {
return
}
func (m *_Model) generate() string {
var pkg genstruct.GenPackage
pkg.SetPackage(m.info.PackageName) //package name
for _, tab := range m.info.TabList {
var sct genstruct.GenStruct
sct.SetStructName(getCamelName(tab.Name)) // Big hump.大驼峰
sct.SetNotes(tab.Notes)
sct.AddElement(m.genTableElement(tab.Em)...) // build element.构造元素
sct.SetCreatTableStr(tab.SQLBuildStr)
pkg.AddStruct(sct)
// GetPackage gen sturct on table
func (m *_Model) GetPackage() genstruct.GenPackage {
if m.pkg == nil {
var pkg genstruct.GenPackage
pkg.SetPackage(m.info.PackageName) //package name
for _, tab := range m.info.TabList {
var sct genstruct.GenStruct
sct.SetStructName(getCamelName(tab.Name)) // Big hump.大驼峰
sct.SetNotes(tab.Notes)
sct.AddElement(m.genTableElement(tab.Em)...) // build element.构造元素
sct.SetCreatTableStr(tab.SQLBuildStr)
pkg.AddStruct(sct)
}
m.pkg = &pkg
}
return pkg.Generate()
return *m.pkg
}
func (m *_Model) generate() string {
m.pkg = nil
m.GetPackage()
return m.pkg.Generate()
}
// genTableElement Get table columns and comments.获取表列及注释
func (m *_Model) genTableElement(cols []ColumusInfo) (el []genstruct.GenElement) {
_tagGorm := config.GetDBTag()
_tagJSON := config.GetURLTag()
for _, v := range cols {
var tmp genstruct.GenElement
if strings.EqualFold(v.Type, "gorm.Model") { // gorm model
@@ -91,7 +105,7 @@ func (m *_Model) genTableElement(cols []ColumusInfo) (el []genstruct.GenElement)
}
// json tag
if config.GetIsJSONTag() {
if config.GetIsWEBTag() {
if strings.EqualFold(v.Name, "id") {
tmp.AddTag(_tagJSON, "-")
} else {
@@ -115,6 +129,9 @@ func (m *_Model) genTableElement(cols []ColumusInfo) (el []genstruct.GenElement)
// genForeignKey Get information about foreign key of table column.获取表列外键相关信息
func (m *_Model) genForeignKey(col ColumusInfo) (fklist []genstruct.GenElement) {
_tagGorm := config.GetDBTag()
_tagJSON := config.GetURLTag()
for _, v := range col.ForeignKeyList {
isMulti, isFind, notes := m.getColumusKeyMulti(v.TableName, v.ColumnName)
if isFind {
@@ -132,7 +149,7 @@ func (m *_Model) genForeignKey(col ColumusInfo) (fklist []genstruct.GenElement)
tmp.AddTag(_tagGorm, "foreignkey:"+v.ColumnName)
// json tag
if config.GetIsJSONTag() {
if config.GetIsWEBTag() {
tmp.AddTag(_tagJSON, mybigcamel.UnMarshal(v.TableName)+"_list")
}

View File

@@ -58,30 +58,6 @@ type UserAccountTbl struct {
-------------
### Complex single table mode export
- param:singular_table = true simple = false is_foreign_key = false
###### --->export result
```
// UserAccountTbl 用户账号
type User_account_tbl struct {
Id int `gorm:"primary_key;column:id;type:int(11);not null" json:"-"`
Account string `gorm:"unique;column:account;type:varchar(64);not null" json:"account"`
Password string `gorm:"column:password;type:varchar(64);not null" json:"password"`
Account_type int `gorm:"column:account_type;type:int(11);not null" json:"account_type"` // 帐号类型:0手机号1邮件
App_key string `gorm:"unique_index:UNIQ_5696AD037D3656A4;column:app_key;type:varchar(255);not null" json:"app_key"` // authbucket_oauth2_client表的id
User_info_tbl_id int `gorm:"unique_index:UNIQ_5696AD037D3656A4;index;column:user_info_tbl_id;type:int(11);not null" json:"user_info_tbl_id"`
Reg_time time.Time `gorm:"column:reg_time;type:datetime" json:"reg_time"`
Reg_ip string `gorm:"column:reg_ip;type:varchar(15)" json:"reg_ip"`
Bundle_id string `gorm:"column:bundle_id;type:varchar(255)" json:"bundle_id"`
Describ string `gorm:"column:describ;type:varchar(255)" json:"describ"`
}
```
-------------
### Simple-export-with-JSON
- param:singular_table = false simple = true is_json_tag = true is_foreign_key = false

View File

@@ -58,30 +58,6 @@ type UserAccountTbl struct {
-------------
### 复杂单表模式导出
- 参数:singular_table = true simple = false is_foreign_key = false
###### --->导出结果
```
// UserAccountTbl 用户账号
type User_account_tbl struct {
Id int `gorm:"primary_key;column:id;type:int(11);not null" json:"-"`
Account string `gorm:"unique;column:account;type:varchar(64);not null" json:"account"`
Password string `gorm:"column:password;type:varchar(64);not null" json:"password"`
Account_type int `gorm:"column:account_type;type:int(11);not null" json:"account_type"` // 帐号类型:0手机号1邮件
App_key string `gorm:"unique_index:UNIQ_5696AD037D3656A4;column:app_key;type:varchar(255);not null" json:"app_key"` // authbucket_oauth2_client表的id
User_info_tbl_id int `gorm:"unique_index:UNIQ_5696AD037D3656A4;index;column:user_info_tbl_id;type:int(11);not null" json:"user_info_tbl_id"`
Reg_time time.Time `gorm:"column:reg_time;type:datetime" json:"reg_time"`
Reg_ip string `gorm:"column:reg_ip;type:varchar(15)" json:"reg_ip"`
Bundle_id string `gorm:"column:bundle_id;type:varchar(255)" json:"bundle_id"`
Describ string `gorm:"column:describ;type:varchar(255)" json:"describ"`
}
```
-------------
### 简单带json导出
- 参数:singular_table = false simple = true is_json_tag = true is_foreign_key = false

6
go.mod
View File

@@ -7,11 +7,15 @@ require (
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-sql-driver/mysql v1.4.1
github.com/jinzhu/gorm v1.9.11
github.com/jroimartin/gocui v0.4.0
github.com/kr/pretty v0.1.0 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/nicksnyder/go-i18n/v2 v2.0.3
github.com/spf13/cobra v0.0.5
github.com/xxjwxc/public v0.0.0-20191107073037-ea6b812d567f
github.com/xxjwxc/public v0.0.0-20200221114751-56810b3fcc29
golang.org/x/text v0.3.2
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/go-playground/validator.v9 v9.30.2
gopkg.in/yaml.v2 v2.2.7
gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2
)

30
go.sum
View File

@@ -2,6 +2,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU=
cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
github.com/BurntSushi/toml v0.3.0/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
@@ -10,6 +11,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
github.com/ant0ine/go-json-rest v3.3.2+incompatible/go.mod h1:q6aCt0GfU6LhpBsnZ/2U+mwe+0XB5WStbmwyoPfc+sk=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/atotto/clipboard v0.1.2 h1:YZCtFu5Ie8qX2VmVTBnrqLSiU9XOWwqNRmdT3gIQzbY=
github.com/atotto/clipboard v0.1.2/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ=
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394/go.mod h1:Q8n74mJTIgjX4RBBcHnJ05h//6/k6foqmgE45jTQtxg=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
@@ -70,6 +73,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jroimartin/gocui v0.4.0 h1:52jnalstgmc25FmtGcWqa0tcbMEWS6RpFLsOIO+I+E8=
github.com/jroimartin/gocui v0.4.0/go.mod h1:7i7bbj99OgFHzo7kB2zPb8pXLqMBSQegY7azfqXMkyY=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kardianos/service v1.0.1-0.20191017145738-4df36c9fc1c6/go.mod h1:8CzDhVuCuugtsHyZoTvsOBuvonN/UDBvl0kH+BUxvbo=
@@ -84,12 +89,21 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
github.com/mattn/go-runewidth v0.0.8 h1:3tS41NlGYSmhhe/8fhGRzc+z3AYCw1Fe1WAyLuujKs0=
github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-sqlite3 v1.11.0 h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q=
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nicksnyder/go-i18n v2.0.3+incompatible h1:XCCaWsCoy4KlWkhOr+63dkv6oJmitJ573uJqDBAiFiQ=
github.com/nicksnyder/go-i18n/v2 v2.0.3 h1:ks/JkQiOEhhuF6jpNvx+Wih1NIiXzUnZeZVnJuI8R8M=
github.com/nicksnyder/go-i18n/v2 v2.0.3/go.mod h1:oDab7q8XCYMRlcrBnaY/7B1eOectbvj6B1UPBT+p5jo=
github.com/nsf/termbox-go v0.0.0-20191229070316-58d4fcbce2a7 h1:OkWEy7aQeQTbgdrcGi9bifx+Y6bMM7ae7y42hDFaBvA=
github.com/nsf/termbox-go v0.0.0-20191229070316-58d4fcbce2a7/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
github.com/olivere/elastic v6.2.26+incompatible/go.mod h1:J+q1zQJTgAz9woqsbVRqGeB5G1iqDKVBWLNSYW8yfJ8=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
@@ -97,6 +111,7 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
@@ -126,12 +141,18 @@ github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljT
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/xxjwxc/public v0.0.0-20191107073037-ea6b812d567f h1:PyaqoUhjkgpBGR/8LXWvk3yzrILMXC7Ygu8xhl5+sM8=
github.com/xxjwxc/public v0.0.0-20191107073037-ea6b812d567f/go.mod h1:j0CCXMUDtykGMfOoBpy1pfmzEeBk2JVusosjbgjfMZg=
github.com/xxjwxc/public v0.0.0-20200120133922-c61314a90a4a h1:sQ+O2UwDj1ShdZ6NLgp98cmaZLWrkFpVJB+wOzj1kDQ=
github.com/xxjwxc/public v0.0.0-20200120133922-c61314a90a4a/go.mod h1:UYQUNNJmUzNKpjY5ctz1n/XoJonmhAIgD51zS2rEsek=
github.com/xxjwxc/public v0.0.0-20200120153226-f36cf754df21 h1:1OF0Q6FGQhmziN4yvHLiF9XXOqfChL5z4rcogSQqCos=
github.com/xxjwxc/public v0.0.0-20200221114751-56810b3fcc29 h1:C0fnjiwnCBjovovCTkrjVXQtqd+UdVD2N8yaVK8LHwk=
github.com/xxjwxc/public v0.0.0-20200221114751-56810b3fcc29/go.mod h1:lhh94GsxhTweM/OaF7eFzOAgVV6fSSbBvA6zOtOVmdU=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190506204251-e1dfcc566284/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
@@ -144,12 +165,15 @@ golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -158,9 +182,12 @@ golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191104094858-e8c54fb511f6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -168,6 +195,7 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
@@ -189,6 +217,8 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2 h1:XZx7nhd5GMaZpmDaEHFVafUZC7ya0fuo7cSJ3UCKYmM=
gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

BIN
image/.DS_Store vendored

Binary file not shown.

BIN
image/gormt/ui_cn.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 952 KiB

BIN
image/gormt/ui_en.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@@ -15,6 +15,6 @@ func TestMain(t *testing.T) {
// out, _ := json.Marshal(pkg)
// tools.WriteFile("test.txt", []string{string(out)}, true)
list := model.Generate(pkg)
list, _ := model.Generate(pkg)
fmt.Println(list)
}