From cd7ddd45a278e810dbb814c22b7395bbac5bde15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E5=B0=8F=E5=86=9B?= <346944475@qq.com> Date: Tue, 10 Dec 2019 17:32:53 +0800 Subject: [PATCH] fix sql call style --- data/view/model/genmysql/genmysql.go | 6 +++--- go.sum | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data/view/model/genmysql/genmysql.go b/data/view/model/genmysql/genmysql.go index 75a0965..4b02d74 100644 --- a/data/view/model/genmysql/genmysql.go +++ b/data/view/model/genmysql/genmysql.go @@ -74,7 +74,7 @@ func getPackageInfo(orm *mysqldb.MySqlDB, info *model.DBInfo) { tab.SQLBuildStr = CreateTable } } - // rows.Close() + rows.Close() // ----------end } @@ -170,7 +170,6 @@ func getTables(orm *mysqldb.MySqlDB) map[string]string { fmt.Println(err) return tbDesc } - // defer rows.Close() for rows.Next() { var table string @@ -178,10 +177,10 @@ func getTables(orm *mysqldb.MySqlDB) map[string]string { tables = append(tables, table) tbDesc[table] = "" } + rows.Close() // Get table annotations.获取表注释 rows1, err := orm.Raw("SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE table_schema= '" + config.GetMysqlDbInfo().Database + "'").Rows() - // defer rows1.Close() if err != nil { fmt.Println(err) return tbDesc @@ -192,6 +191,7 @@ func getTables(orm *mysqldb.MySqlDB) map[string]string { rows1.Scan(&table, &desc) tbDesc[table] = desc } + rows1.Close() return tbDesc } diff --git a/go.sum b/go.sum index 5a30e46..e56a03b 100644 --- a/go.sum +++ b/go.sum @@ -56,6 +56,7 @@ github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jander/golog v0.0.0-20150917071935-954a5be801fc/go.mod h1:uWhWXOR4dpfk9J8fegnMY7sP2GFXxe3PFI9Ps+TRXJs= github.com/jinzhu/gorm v1.9.11 h1:gaHGvE+UnWGlbWG4Y3FUwY1EcZ5n6S9WtqBA/uySMLE=