1.golang sql2struct

1.1 go代码实现
package main

import (
"fmt"
"github.com/gohouse/converter"
)
func main() {
	err := converter.NewTable2Struct().
		SavePath("/home/xxx/Desktop/model.go").
		Dsn("root:123456@tcp(localhost:3306)/test?charset=utf8").
		Run()
	fmt.Println(err)
}
1.2 命令行模式
//1.下载二进制文件
https://github.com/gohouse/converter/releases

//2.执行命令
./table2struct-linux.v0.0.3.bin -file /home/xxx/Desktop/mode.go  -dsn "root:123456@tcp(localhost:3306)/test?charset=utf8"

//3.参数说明
-dsn            string 数据库dsn配置
-enableJsonTag  bool 是否添加json的tag
-file           string 保存路径
-packageName    string 包名
-prefix         string 表前缀
-realNameMethod string 结构体对应的表名
-table          string 要迁移的表
-tagKey         string tag的key

相关链接

https://github.com/gohouse/converter/releases

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐