golang sql2struct


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM