Skip to content

Commit b47cf57

Browse files
author
kinggo
authored
ci: add gofumpt check in reviewdog (#4973)
1 parent 4dd2647 commit b47cf57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+244
-235
lines changed

.github/workflows/reviewdog.yml

+11
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,14 @@ jobs:
99
uses: actions/checkout@v2
1010
- name: golangci-lint
1111
uses: reviewdog/action-golangci-lint@v2
12+
13+
- name: Setup reviewdog
14+
uses: reviewdog/action-setup@v1
15+
16+
- name: gofumpt -s with reviewdog
17+
env:
18+
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
run: |
20+
go install mvdan.cc/gofumpt@v0.2.0
21+
gofumpt -e -d . | \
22+
reviewdog -name="gofumpt" -f=diff -f.diff.strip=0 -reporter=github-pr-review

callbacks/helper.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func ConvertMapToValuesForCreate(stmt *gorm.Statement, mapValue map[string]inter
1212
values.Columns = make([]clause.Column, 0, len(mapValue))
1313
selectColumns, restricted := stmt.SelectAndOmitColumns(true, false)
1414

15-
var keys = make([]string, 0, len(mapValue))
15+
keys := make([]string, 0, len(mapValue))
1616
for k := range mapValue {
1717
keys = append(keys, k)
1818
}
@@ -40,9 +40,7 @@ func ConvertMapToValuesForCreate(stmt *gorm.Statement, mapValue map[string]inter
4040

4141
// ConvertSliceOfMapToValuesForCreate convert slice of map to values
4242
func ConvertSliceOfMapToValuesForCreate(stmt *gorm.Statement, mapValues []map[string]interface{}) (values clause.Values) {
43-
var (
44-
columns = make([]string, 0, len(mapValues))
45-
)
43+
columns := make([]string, 0, len(mapValues))
4644

4745
// when the length of mapValues is zero,return directly here
4846
// no need to call stmt.SelectAndOmitColumns method

callbacks/update.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func ConvertToAssignments(stmt *gorm.Statement) (set clause.Set) {
162162
if size := stmt.ReflectValue.Len(); size > 0 {
163163
var primaryKeyExprs []clause.Expression
164164
for i := 0; i < size; i++ {
165-
var exprs = make([]clause.Expression, len(stmt.Schema.PrimaryFields))
165+
exprs := make([]clause.Expression, len(stmt.Schema.PrimaryFields))
166166
var notZero bool
167167
for idx, field := range stmt.Schema.PrimaryFields {
168168
value, isZero := field.ValueOf(stmt.ReflectValue.Index(i))
@@ -242,7 +242,7 @@ func ConvertToAssignments(stmt *gorm.Statement) (set clause.Set) {
242242
}
243243
}
244244
default:
245-
var updatingSchema = stmt.Schema
245+
updatingSchema := stmt.Schema
246246
if !updatingValue.CanAddr() || stmt.Dest != stmt.Model {
247247
// different schema
248248
updatingStmt := &gorm.Statement{DB: stmt.DB}

clause/benchmarks_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ func BenchmarkComplexSelect(b *testing.B) {
3232
for i := 0; i < b.N; i++ {
3333
stmt := gorm.Statement{DB: db, Table: user.Table, Schema: user, Clauses: map[string]clause.Clause{}}
3434
clauses := []clause.Interface{
35-
clause.Select{}, clause.From{},
35+
clause.Select{},
36+
clause.From{},
3637
clause.Where{Exprs: []clause.Expression{
3738
clause.Eq{Column: clause.PrimaryColumn, Value: "1"},
3839
clause.Gt{Column: "age", Value: 18},

clause/group_by_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ func TestGroupBy(t *testing.T) {
1818
Columns: []clause.Column{{Name: "role"}},
1919
Having: []clause.Expression{clause.Eq{"role", "admin"}},
2020
}},
21-
"SELECT * FROM `users` GROUP BY `role` HAVING `role` = ?", []interface{}{"admin"},
21+
"SELECT * FROM `users` GROUP BY `role` HAVING `role` = ?",
22+
[]interface{}{"admin"},
2223
},
2324
{
2425
[]clause.Interface{clause.Select{}, clause.From{}, clause.GroupBy{
@@ -28,7 +29,8 @@ func TestGroupBy(t *testing.T) {
2829
Columns: []clause.Column{{Name: "gender"}},
2930
Having: []clause.Expression{clause.Neq{"gender", "U"}},
3031
}},
31-
"SELECT * FROM `users` GROUP BY `role`,`gender` HAVING `role` = ? AND `gender` <> ?", []interface{}{"admin", "U"},
32+
"SELECT * FROM `users` GROUP BY `role`,`gender` HAVING `role` = ? AND `gender` <> ?",
33+
[]interface{}{"admin", "U"},
3234
},
3335
}
3436

clause/order_by_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ func TestOrderBy(t *testing.T) {
4545
Expression: clause.Expr{SQL: "FIELD(id, ?)", Vars: []interface{}{[]int{1, 2, 3}}, WithoutParentheses: true},
4646
},
4747
},
48-
"SELECT * FROM `users` ORDER BY FIELD(id, ?,?,?)", []interface{}{1, 2, 3},
48+
"SELECT * FROM `users` ORDER BY FIELD(id, ?,?,?)",
49+
[]interface{}{1, 2, 3},
4950
},
5051
}
5152

clause/set_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ func TestSet(t *testing.T) {
2020
clause.Update{},
2121
clause.Set([]clause.Assignment{{clause.PrimaryColumn, 1}}),
2222
},
23-
"UPDATE `users` SET `users`.`id`=?", []interface{}{1},
23+
"UPDATE `users` SET `users`.`id`=?",
24+
[]interface{}{1},
2425
},
2526
{
2627
[]clause.Interface{
2728
clause.Update{},
2829
clause.Set([]clause.Assignment{{clause.PrimaryColumn, 1}}),
2930
clause.Set([]clause.Assignment{{clause.Column{Name: "name"}, "jinzhu"}}),
3031
},
31-
"UPDATE `users` SET `name`=?", []interface{}{"jinzhu"},
32+
"UPDATE `users` SET `name`=?",
33+
[]interface{}{"jinzhu"},
3234
},
3335
}
3436

clause/values_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ func TestValues(t *testing.T) {
2121
Values: [][]interface{}{{"jinzhu", 18}, {"josh", 1}},
2222
},
2323
},
24-
"INSERT INTO `users` (`name`,`age`) VALUES (?,?),(?,?)", []interface{}{"jinzhu", 18, "josh", 1},
24+
"INSERT INTO `users` (`name`,`age`) VALUES (?,?),(?,?)",
25+
[]interface{}{"jinzhu", 18, "josh", 1},
2526
},
2627
}
2728

clause/where_test.go

+14-7
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,54 @@ func TestWhere(t *testing.T) {
1717
[]clause.Interface{clause.Select{}, clause.From{}, clause.Where{
1818
Exprs: []clause.Expression{clause.Eq{Column: clause.PrimaryColumn, Value: "1"}, clause.Gt{Column: "age", Value: 18}, clause.Or(clause.Neq{Column: "name", Value: "jinzhu"})},
1919
}},
20-
"SELECT * FROM `users` WHERE `users`.`id` = ? AND `age` > ? OR `name` <> ?", []interface{}{"1", 18, "jinzhu"},
20+
"SELECT * FROM `users` WHERE `users`.`id` = ? AND `age` > ? OR `name` <> ?",
21+
[]interface{}{"1", 18, "jinzhu"},
2122
},
2223
{
2324
[]clause.Interface{clause.Select{}, clause.From{}, clause.Where{
2425
Exprs: []clause.Expression{clause.Or(clause.Neq{Column: "name", Value: "jinzhu"}), clause.Eq{Column: clause.PrimaryColumn, Value: "1"}, clause.Gt{Column: "age", Value: 18}},
2526
}},
26-
"SELECT * FROM `users` WHERE `users`.`id` = ? OR `name` <> ? AND `age` > ?", []interface{}{"1", "jinzhu", 18},
27+
"SELECT * FROM `users` WHERE `users`.`id` = ? OR `name` <> ? AND `age` > ?",
28+
[]interface{}{"1", "jinzhu", 18},
2729
},
2830
{
2931
[]clause.Interface{clause.Select{}, clause.From{}, clause.Where{
3032
Exprs: []clause.Expression{clause.Or(clause.Neq{Column: "name", Value: "jinzhu"}), clause.Eq{Column: clause.PrimaryColumn, Value: "1"}, clause.Gt{Column: "age", Value: 18}},
3133
}},
32-
"SELECT * FROM `users` WHERE `users`.`id` = ? OR `name` <> ? AND `age` > ?", []interface{}{"1", "jinzhu", 18},
34+
"SELECT * FROM `users` WHERE `users`.`id` = ? OR `name` <> ? AND `age` > ?",
35+
[]interface{}{"1", "jinzhu", 18},
3336
},
3437
{
3538
[]clause.Interface{clause.Select{}, clause.From{}, clause.Where{
3639
Exprs: []clause.Expression{clause.Or(clause.Eq{Column: clause.PrimaryColumn, Value: "1"}), clause.Or(clause.Neq{Column: "name", Value: "jinzhu"})},
3740
}},
38-
"SELECT * FROM `users` WHERE `users`.`id` = ? OR `name` <> ?", []interface{}{"1", "jinzhu"},
41+
"SELECT * FROM `users` WHERE `users`.`id` = ? OR `name` <> ?",
42+
[]interface{}{"1", "jinzhu"},
3943
},
4044
{
4145
[]clause.Interface{clause.Select{}, clause.From{}, clause.Where{
4246
Exprs: []clause.Expression{clause.Eq{Column: clause.PrimaryColumn, Value: "1"}, clause.Gt{Column: "age", Value: 18}, clause.Or(clause.Neq{Column: "name", Value: "jinzhu"})},
4347
}, clause.Where{
4448
Exprs: []clause.Expression{clause.Or(clause.Gt{Column: "score", Value: 100}, clause.Like{Column: "name", Value: "%linus%"})},
4549
}},
46-
"SELECT * FROM `users` WHERE `users`.`id` = ? AND `age` > ? OR `name` <> ? AND (`score` > ? OR `name` LIKE ?)", []interface{}{"1", 18, "jinzhu", 100, "%linus%"},
50+
"SELECT * FROM `users` WHERE `users`.`id` = ? AND `age` > ? OR `name` <> ? AND (`score` > ? OR `name` LIKE ?)",
51+
[]interface{}{"1", 18, "jinzhu", 100, "%linus%"},
4752
},
4853
{
4954
[]clause.Interface{clause.Select{}, clause.From{}, clause.Where{
5055
Exprs: []clause.Expression{clause.Not(clause.Eq{Column: clause.PrimaryColumn, Value: "1"}, clause.Gt{Column: "age", Value: 18}), clause.Or(clause.Neq{Column: "name", Value: "jinzhu"})},
5156
}, clause.Where{
5257
Exprs: []clause.Expression{clause.Or(clause.Not(clause.Gt{Column: "score", Value: 100}), clause.Like{Column: "name", Value: "%linus%"})},
5358
}},
54-
"SELECT * FROM `users` WHERE (`users`.`id` <> ? AND `age` <= ?) OR `name` <> ? AND (`score` <= ? OR `name` LIKE ?)", []interface{}{"1", 18, "jinzhu", 100, "%linus%"},
59+
"SELECT * FROM `users` WHERE (`users`.`id` <> ? AND `age` <= ?) OR `name` <> ? AND (`score` <= ? OR `name` LIKE ?)",
60+
[]interface{}{"1", 18, "jinzhu", 100, "%linus%"},
5561
},
5662
{
5763
[]clause.Interface{clause.Select{}, clause.From{}, clause.Where{
5864
Exprs: []clause.Expression{clause.And(clause.Eq{Column: "age", Value: 18}, clause.Or(clause.Neq{Column: "name", Value: "jinzhu"}))},
5965
}},
60-
"SELECT * FROM `users` WHERE (`age` = ? OR `name` <> ?)", []interface{}{18, "jinzhu"},
66+
"SELECT * FROM `users` WHERE (`age` = ? OR `name` <> ?)",
67+
[]interface{}{18, "jinzhu"},
6168
},
6269
}
6370

clause/with.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
package clause
22

3-
type With struct {
4-
}
3+
type With struct{}

logger/sql.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var convertibleTypes = []reflect.Type{reflect.TypeOf(time.Time{}), reflect.TypeO
3232

3333
func ExplainSQL(sql string, numericPlaceholder *regexp.Regexp, escaper string, avars ...interface{}) string {
3434
var convertParams func(interface{}, int)
35-
var vars = make([]string, len(avars))
35+
vars := make([]string, len(avars))
3636

3737
convertParams = func(v interface{}, idx int) {
3838
switch v := v.(type) {

migrator/migrator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ func (m Migrator) CreateConstraint(value interface{}, name string) error {
541541
}
542542

543543
if constraint != nil {
544-
var vars = []interface{}{clause.Table{Name: table}}
544+
vars := []interface{}{clause.Table{Name: table}}
545545
if stmt.TableExpr != nil {
546546
vars[0] = stmt.TableExpr
547547
}

schema/callbacks_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import (
99
"gorm.io/gorm/schema"
1010
)
1111

12-
type UserWithCallback struct {
13-
}
12+
type UserWithCallback struct{}
1413

1514
func (UserWithCallback) BeforeSave(*gorm.DB) error {
1615
return nil

schema/check.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import (
55
"strings"
66
)
77

8-
var (
9-
// reg match english letters and midline
10-
regEnLetterAndMidline = regexp.MustCompile("^[A-Za-z-_]+$")
11-
)
8+
// reg match english letters and midline
9+
var regEnLetterAndMidline = regexp.MustCompile("^[A-Za-z-_]+$")
1210

1311
type Check struct {
1412
Name string
@@ -18,7 +16,7 @@ type Check struct {
1816

1917
// ParseCheckConstraints parse schema check constraints
2018
func (schema *Schema) ParseCheckConstraints() map[string]Check {
21-
var checks = map[string]Check{}
19+
checks := map[string]Check{}
2220
for _, field := range schema.FieldsByDBName {
2321
if chk := field.TagSettings["CHECK"]; chk != "" {
2422
names := strings.Split(chk, ",")

schema/field.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field {
398398
ef.TagSettings[k] = v
399399
}
400400
}
401-
case reflect.Invalid, reflect.Uintptr, reflect.Array, reflect.Chan, reflect.Func, reflect.Interface,
402-
reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer, reflect.Complex64, reflect.Complex128:
401+
case reflect.Invalid, reflect.Uintptr, reflect.Array, reflect.Chan, reflect.Func, reflect.Interface,
402+
reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer, reflect.Complex64, reflect.Complex128:
403403
schema.err = fmt.Errorf("invalid embedded struct for %s's field %s, should be struct, but got %v", field.Schema.Name, field.Name, field.FieldType)
404404
}
405405
}

schema/field_test.go

+51-49
Original file line numberDiff line numberDiff line change
@@ -261,64 +261,66 @@ func TestParseFieldWithPermission(t *testing.T) {
261261
}
262262
}
263263

264-
type ID int64
265-
type INT int
266-
type INT8 int8
267-
type INT16 int16
268-
type INT32 int32
269-
type INT64 int64
270-
type UINT uint
271-
type UINT8 uint8
272-
type UINT16 uint16
273-
type UINT32 uint32
274-
type UINT64 uint64
275-
type FLOAT32 float32
276-
type FLOAT64 float64
277-
type BOOL bool
278-
type STRING string
279-
type TypeAlias struct {
280-
ID
281-
INT `gorm:"column:fint"`
282-
INT8 `gorm:"column:fint8"`
283-
INT16 `gorm:"column:fint16"`
284-
INT32 `gorm:"column:fint32"`
285-
INT64 `gorm:"column:fint64"`
286-
UINT `gorm:"column:fuint"`
287-
UINT8 `gorm:"column:fuint8"`
288-
UINT16 `gorm:"column:fuint16"`
289-
UINT32 `gorm:"column:fuint32"`
290-
UINT64 `gorm:"column:fuint64"`
291-
FLOAT32 `gorm:"column:ffloat32"`
292-
FLOAT64 `gorm:"column:ffloat64"`
293-
BOOL `gorm:"column:fbool"`
294-
STRING `gorm:"column:fstring"`
295-
}
264+
type (
265+
ID int64
266+
INT int
267+
INT8 int8
268+
INT16 int16
269+
INT32 int32
270+
INT64 int64
271+
UINT uint
272+
UINT8 uint8
273+
UINT16 uint16
274+
UINT32 uint32
275+
UINT64 uint64
276+
FLOAT32 float32
277+
FLOAT64 float64
278+
BOOL bool
279+
STRING string
280+
TypeAlias struct {
281+
ID
282+
INT `gorm:"column:fint"`
283+
INT8 `gorm:"column:fint8"`
284+
INT16 `gorm:"column:fint16"`
285+
INT32 `gorm:"column:fint32"`
286+
INT64 `gorm:"column:fint64"`
287+
UINT `gorm:"column:fuint"`
288+
UINT8 `gorm:"column:fuint8"`
289+
UINT16 `gorm:"column:fuint16"`
290+
UINT32 `gorm:"column:fuint32"`
291+
UINT64 `gorm:"column:fuint64"`
292+
FLOAT32 `gorm:"column:ffloat32"`
293+
FLOAT64 `gorm:"column:ffloat64"`
294+
BOOL `gorm:"column:fbool"`
295+
STRING `gorm:"column:fstring"`
296+
}
297+
)
296298

297-
func TestTypeAliasField(t *testing.T){
299+
func TestTypeAliasField(t *testing.T) {
298300
alias, err := schema.Parse(&TypeAlias{}, &sync.Map{}, schema.NamingStrategy{})
299301
if err != nil {
300302
t.Fatalf("Failed to parse TypeAlias with permission, got error %v", err)
301303
}
302304

303305
fields := []*schema.Field{
304-
{Name: "ID", DBName: "id", BindNames: []string{"ID"}, DataType: schema.Int , Creatable: true, Updatable: true, Readable: true, Size: 64, PrimaryKey: true, HasDefaultValue: true, AutoIncrement: true },
305-
{Name: "INT", DBName: "fint", BindNames: []string{"INT"}, DataType: schema.Int , Creatable: true, Updatable: true, Readable: true, Size: 64, Tag: `gorm:"column:fint"`},
306-
{Name: "INT8", DBName: "fint8", BindNames: []string{"INT8"}, DataType: schema.Int , Creatable: true, Updatable: true, Readable: true, Size: 8, Tag: `gorm:"column:fint8"`},
307-
{Name: "INT16", DBName: "fint16", BindNames: []string{"INT16"}, DataType: schema.Int , Creatable: true, Updatable: true, Readable: true, Size: 16, Tag: `gorm:"column:fint16"`},
308-
{Name: "INT32", DBName: "fint32", BindNames: []string{"INT32"}, DataType: schema.Int , Creatable: true, Updatable: true, Readable: true, Size: 32, Tag: `gorm:"column:fint32"`},
309-
{Name: "INT64", DBName: "fint64", BindNames: []string{"INT64"}, DataType: schema.Int , Creatable: true, Updatable: true, Readable: true, Size: 64, Tag: `gorm:"column:fint64"`},
310-
{Name: "UINT", DBName: "fuint", BindNames: []string{"UINT"}, DataType: schema.Uint , Creatable: true, Updatable: true, Readable: true, Size: 64, Tag: `gorm:"column:fuint"`},
311-
{Name: "UINT8", DBName: "fuint8", BindNames: []string{"UINT8"}, DataType: schema.Uint , Creatable: true, Updatable: true, Readable: true, Size: 8, Tag: `gorm:"column:fuint8"`},
312-
{Name: "UINT16", DBName: "fuint16", BindNames: []string{"UINT16"}, DataType: schema.Uint , Creatable: true, Updatable: true, Readable: true, Size: 16, Tag: `gorm:"column:fuint16"`},
313-
{Name: "UINT32", DBName: "fuint32", BindNames: []string{"UINT32"}, DataType: schema.Uint , Creatable: true, Updatable: true, Readable: true, Size: 32, Tag: `gorm:"column:fuint32"`},
314-
{Name: "UINT64", DBName: "fuint64", BindNames: []string{"UINT64"}, DataType: schema.Uint , Creatable: true, Updatable: true, Readable: true, Size: 64, Tag: `gorm:"column:fuint64"`},
315-
{Name: "FLOAT32", DBName: "ffloat32", BindNames: []string{"FLOAT32"}, DataType: schema.Float , Creatable: true, Updatable: true, Readable: true, Size: 32, Tag: `gorm:"column:ffloat32"`},
316-
{Name: "FLOAT64", DBName: "ffloat64", BindNames: []string{"FLOAT64"}, DataType: schema.Float , Creatable: true, Updatable: true, Readable: true, Size: 64, Tag: `gorm:"column:ffloat64"`},
317-
{Name: "BOOL", DBName: "fbool", BindNames: []string{"BOOL"}, DataType: schema.Bool , Creatable: true, Updatable: true, Readable: true, Tag: `gorm:"column:fbool"`},
318-
{Name: "STRING", DBName: "fstring", BindNames: []string{"STRING"}, DataType: schema.String, Creatable: true, Updatable: true, Readable: true, Tag: `gorm:"column:fstring"`},
306+
{Name: "ID", DBName: "id", BindNames: []string{"ID"}, DataType: schema.Int, Creatable: true, Updatable: true, Readable: true, Size: 64, PrimaryKey: true, HasDefaultValue: true, AutoIncrement: true},
307+
{Name: "INT", DBName: "fint", BindNames: []string{"INT"}, DataType: schema.Int, Creatable: true, Updatable: true, Readable: true, Size: 64, Tag: `gorm:"column:fint"`},
308+
{Name: "INT8", DBName: "fint8", BindNames: []string{"INT8"}, DataType: schema.Int, Creatable: true, Updatable: true, Readable: true, Size: 8, Tag: `gorm:"column:fint8"`},
309+
{Name: "INT16", DBName: "fint16", BindNames: []string{"INT16"}, DataType: schema.Int, Creatable: true, Updatable: true, Readable: true, Size: 16, Tag: `gorm:"column:fint16"`},
310+
{Name: "INT32", DBName: "fint32", BindNames: []string{"INT32"}, DataType: schema.Int, Creatable: true, Updatable: true, Readable: true, Size: 32, Tag: `gorm:"column:fint32"`},
311+
{Name: "INT64", DBName: "fint64", BindNames: []string{"INT64"}, DataType: schema.Int, Creatable: true, Updatable: true, Readable: true, Size: 64, Tag: `gorm:"column:fint64"`},
312+
{Name: "UINT", DBName: "fuint", BindNames: []string{"UINT"}, DataType: schema.Uint, Creatable: true, Updatable: true, Readable: true, Size: 64, Tag: `gorm:"column:fuint"`},
313+
{Name: "UINT8", DBName: "fuint8", BindNames: []string{"UINT8"}, DataType: schema.Uint, Creatable: true, Updatable: true, Readable: true, Size: 8, Tag: `gorm:"column:fuint8"`},
314+
{Name: "UINT16", DBName: "fuint16", BindNames: []string{"UINT16"}, DataType: schema.Uint, Creatable: true, Updatable: true, Readable: true, Size: 16, Tag: `gorm:"column:fuint16"`},
315+
{Name: "UINT32", DBName: "fuint32", BindNames: []string{"UINT32"}, DataType: schema.Uint, Creatable: true, Updatable: true, Readable: true, Size: 32, Tag: `gorm:"column:fuint32"`},
316+
{Name: "UINT64", DBName: "fuint64", BindNames: []string{"UINT64"}, DataType: schema.Uint, Creatable: true, Updatable: true, Readable: true, Size: 64, Tag: `gorm:"column:fuint64"`},
317+
{Name: "FLOAT32", DBName: "ffloat32", BindNames: []string{"FLOAT32"}, DataType: schema.Float, Creatable: true, Updatable: true, Readable: true, Size: 32, Tag: `gorm:"column:ffloat32"`},
318+
{Name: "FLOAT64", DBName: "ffloat64", BindNames: []string{"FLOAT64"}, DataType: schema.Float, Creatable: true, Updatable: true, Readable: true, Size: 64, Tag: `gorm:"column:ffloat64"`},
319+
{Name: "BOOL", DBName: "fbool", BindNames: []string{"BOOL"}, DataType: schema.Bool, Creatable: true, Updatable: true, Readable: true, Tag: `gorm:"column:fbool"`},
320+
{Name: "STRING", DBName: "fstring", BindNames: []string{"STRING"}, DataType: schema.String, Creatable: true, Updatable: true, Readable: true, Tag: `gorm:"column:fstring"`},
319321
}
320322

321323
for _, f := range fields {
322324
checkSchemaField(t, alias, f, func(f *schema.Field) {})
323325
}
324-
}
326+
}

schema/index.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type IndexOption struct {
2727

2828
// ParseIndexes parse schema indexes
2929
func (schema *Schema) ParseIndexes() map[string]Index {
30-
var indexes = map[string]Index{}
30+
indexes := map[string]Index{}
3131

3232
for _, field := range schema.Fields {
3333
if field.TagSettings["INDEX"] != "" || field.TagSettings["UNIQUEINDEX"] != "" {

schema/model_test.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ type User struct {
2626
Active *bool
2727
}
2828

29-
type mytime time.Time
30-
type myint int
31-
type mybool = bool
29+
type (
30+
mytime time.Time
31+
myint int
32+
mybool = bool
33+
)
3234

3335
type AdvancedDataTypeUser struct {
3436
ID sql.NullInt64

0 commit comments

Comments
 (0)