From f6db0286a265783601e9c2d372c9fbd39940a3cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Mon, 25 Oct 2021 21:05:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BB=93=E6=9E=84=E4=BD=93?= =?UTF-8?q?=E6=8B=BC=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tool/sql2go/parser.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tool/sql2go/parser.go b/tool/sql2go/parser.go index c497cf1..e92331f 100644 --- a/tool/sql2go/parser.go +++ b/tool/sql2go/parser.go @@ -8,7 +8,6 @@ package sql2go import ( - "fmt" "strings" "git.zhangdeman.cn/zhangdeman/gopkg/util" @@ -37,6 +36,8 @@ func ParseCreateTableSql(sql string) (string, error) { } r := stmt.(*sqlparser.DDL) + structResult := "type " + util.SnakeCaseToCamel(sqlparser.String(r.NewName)) + " struct { \n" + for _, item := range r.TableSpec.Columns { data := map[string]string{ "{FIELD}": util.SnakeCaseToCamel(item.Name.String()), @@ -56,7 +57,8 @@ func ParseCreateTableSql(sql string) (string, error) { for k, v := range data { val = strings.ReplaceAll(val, k, v) } - fmt.Println(val) + structResult += val + "\n" } - return "", nil + structResult = structResult + "}" + return structResult, nil }