chore: update code format. (#628)

This commit is contained in:
Bo-Yi Wu
2021-04-15 19:49:17 +08:00
committed by GitHub
parent 7e087de6e6
commit afd9ff889e
68 changed files with 390 additions and 414 deletions

View File

@@ -68,7 +68,7 @@ func TestBuilderSql(t *testing.T) {
}
func TestBuildSqlDefaultValue(t *testing.T) {
var eq = builder.Eq{}
eq := builder.Eq{}
eq["age"] = 0
eq["user_name"] = ""

View File

@@ -230,7 +230,7 @@ func (g *defaultGenerator) genModel(in parser.Table, withCache bool) (string, er
return "", err
}
var findCode = make([]string, 0)
findCode := make([]string, 0)
findOneCode, findOneCodeMethod, err := genFindOne(table, withCache)
if err != nil {
return "", err

View File

@@ -15,9 +15,7 @@ import (
"github.com/tal-tech/go-zero/tools/goctl/model/sql/builderx"
)
var (
source = "CREATE TABLE `test_user` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `mobile` varchar(255) COLLATE utf8mb4_bin NOT NULL,\n `class` bigint NOT NULL,\n `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,\n `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,\n `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`),\n UNIQUE KEY `mobile_unique` (`mobile`),\n UNIQUE KEY `class_name_unique` (`class`,`name`),\n KEY `create_index` (`create_time`),\n KEY `name_index` (`name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;"
)
var source = "CREATE TABLE `test_user` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `mobile` varchar(255) COLLATE utf8mb4_bin NOT NULL,\n `class` bigint NOT NULL,\n `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,\n `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,\n `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`),\n UNIQUE KEY `mobile_unique` (`mobile`),\n UNIQUE KEY `class_name_unique` (`class`,`name`),\n KEY `create_index` (`create_time`),\n KEY `name_index` (`name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;"
func TestCacheModel(t *testing.T) {
logx.Disable()

View File

@@ -134,7 +134,6 @@ func TestGenCacheKeys(t *testing.T) {
return true
}())
})
}
func cacheKeyEqual(k1 Key, k2 Key) bool {
@@ -161,5 +160,4 @@ func cacheKeyEqual(k1 Key, k2 Key) bool {
k1.DataKeyRight == k2.DataKeyRight &&
k1.DataKeyExpression == k2.DataKeyExpression &&
k1.KeyExpression == k2.KeyExpression
}

View File

@@ -165,7 +165,7 @@ func convertColumns(columns []*sqlparser.ColumnDefinition, primaryColumn string)
comment = string(column.Type.Comment.Val)
}
var isDefaultNull = true
isDefaultNull := true
if column.Type.NotNull {
isDefaultNull = false
} else {