From d11c424334b8964e48c4226f0c91ea9e4c062910 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sun, 7 Jun 2020 15:24:34 +0800 Subject: [PATCH] Fix typo --- callbacks.go | 12 ++++++------ callbacks/helper.go | 2 +- callbacks/update.go | 2 +- tests/associations_belongs_to_test.go | 2 +- tests/associations_has_many_test.go | 12 ++++++------ tests/associations_has_one_test.go | 4 ++-- tests/associations_many2many_test.go | 8 ++++---- tests/migrate_test.go | 2 +- tests/scanner_valuer_test.go | 2 +- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/callbacks.go b/callbacks.go index 4f700081..e6cf29af 100644 --- a/callbacks.go +++ b/callbacks.go @@ -15,12 +15,12 @@ import ( func initializeCallbacks(db *DB) *callbacks { return &callbacks{ processors: map[string]*processor{ - "create": &processor{db: db}, - "query": &processor{db: db}, - "update": &processor{db: db}, - "delete": &processor{db: db}, - "row": &processor{db: db}, - "raw": &processor{db: db}, + "create": {db: db}, + "query": {db: db}, + "update": {db: db}, + "delete": {db: db}, + "row": {db: db}, + "raw": {db: db}, }, } } diff --git a/callbacks/helper.go b/callbacks/helper.go index 828e025a..97c8ad35 100644 --- a/callbacks/helper.go +++ b/callbacks/helper.go @@ -62,7 +62,7 @@ func ConvertMapToValuesForCreate(stmt *gorm.Statement, mapValue map[string]inter selectColumns, restricted := SelectAndOmitColumns(stmt, true, false) var keys []string - for k, _ := range mapValue { + for k := range mapValue { keys = append(keys, k) } sort.Strings(keys) diff --git a/callbacks/update.go b/callbacks/update.go index a41a3c59..f5287dc6 100644 --- a/callbacks/update.go +++ b/callbacks/update.go @@ -141,7 +141,7 @@ func ConvertToAssignments(stmt *gorm.Statement) (set clause.Set) { set = make([]clause.Assignment, 0, len(value)) var keys []string - for k, _ := range value { + for k := range value { keys = append(keys, k) } sort.Strings(keys) diff --git a/tests/associations_belongs_to_test.go b/tests/associations_belongs_to_test.go index 35419666..1800be91 100644 --- a/tests/associations_belongs_to_test.go +++ b/tests/associations_belongs_to_test.go @@ -180,7 +180,7 @@ func TestBelongsToAssociationForSlice(t *testing.T) { // Delete if err := DB.Model(&users).Association("Company").Delete(&users[0].Company); err != nil { - t.Errorf("no error should happend when deleting company, but got %v", err) + t.Errorf("no error should happened when deleting company, but got %v", err) } if users[0].CompanyID != nil || users[0].Company.ID != 0 { diff --git a/tests/associations_has_many_test.go b/tests/associations_has_many_test.go index 7ef0c218..d8befd8a 100644 --- a/tests/associations_has_many_test.go +++ b/tests/associations_has_many_test.go @@ -234,13 +234,13 @@ func TestHasManyAssociationForSlice(t *testing.T) { // Delete if err := DB.Model(&users).Association("Pets").Delete(&users[2].Pets); err != nil { - t.Errorf("no error should happend when deleting pet, but got %v", err) + t.Errorf("no error should happened when deleting pet, but got %v", err) } AssertAssociationCount(t, users, "Pets", 4, "after delete") if err := DB.Model(&users).Association("Pets").Delete(users[0].Pets[0], users[1].Pets[1]); err != nil { - t.Errorf("no error should happend when deleting pet, but got %v", err) + t.Errorf("no error should happened when deleting pet, but got %v", err) } AssertAssociationCount(t, users, "Pets", 2, "after delete") @@ -290,13 +290,13 @@ func TestSingleTableHasManyAssociationForSlice(t *testing.T) { // Delete if err := DB.Model(&users).Association("Team").Delete(&users[2].Team); err != nil { - t.Errorf("no error should happend when deleting pet, but got %v", err) + t.Errorf("no error should happened when deleting pet, but got %v", err) } AssertAssociationCount(t, users, "Team", 4, "after delete") if err := DB.Model(&users).Association("Team").Delete(users[0].Team[0], users[1].Team[1]); err != nil { - t.Errorf("no error should happend when deleting pet, but got %v", err) + t.Errorf("no error should happened when deleting pet, but got %v", err) } AssertAssociationCount(t, users, "Team", 2, "after delete") @@ -439,13 +439,13 @@ func TestPolymorphicHasManyAssociationForSlice(t *testing.T) { // Delete if err := DB.Model(&users).Association("Toys").Delete(&users[2].Toys); err != nil { - t.Errorf("no error should happend when deleting toy, but got %v", err) + t.Errorf("no error should happened when deleting toy, but got %v", err) } AssertAssociationCount(t, users, "Toys", 4, "after delete") if err := DB.Model(&users).Association("Toys").Delete(users[0].Toys[0], users[1].Toys[1]); err != nil { - t.Errorf("no error should happend when deleting toy, but got %v", err) + t.Errorf("no error should happened when deleting toy, but got %v", err) } AssertAssociationCount(t, users, "Toys", 2, "after delete") diff --git a/tests/associations_has_one_test.go b/tests/associations_has_one_test.go index f32a692d..a6dcc6c5 100644 --- a/tests/associations_has_one_test.go +++ b/tests/associations_has_one_test.go @@ -113,7 +113,7 @@ func TestHasOneAssociationForSlice(t *testing.T) { // Delete if err := DB.Model(&users).Association("Account").Delete(&users[0].Account); err != nil { - t.Errorf("no error should happend when deleting account, but got %v", err) + t.Errorf("no error should happened when deleting account, but got %v", err) } AssertAssociationCount(t, users, "Account", 2, "after delete") @@ -230,7 +230,7 @@ func TestPolymorphicHasOneAssociationForSlice(t *testing.T) { // Delete if err := DB.Model(&pets).Association("Toy").Delete(&pets[0].Toy); err != nil { - t.Errorf("no error should happend when deleting toy, but got %v", err) + t.Errorf("no error should happened when deleting toy, but got %v", err) } AssertAssociationCount(t, pets, "Toy", 2, "after delete") diff --git a/tests/associations_many2many_test.go b/tests/associations_many2many_test.go index ba9695b7..2ecf7b66 100644 --- a/tests/associations_many2many_test.go +++ b/tests/associations_many2many_test.go @@ -147,13 +147,13 @@ func TestMany2ManyAssociationForSlice(t *testing.T) { // Delete if err := DB.Model(&users).Association("Languages").Delete(&users[2].Languages); err != nil { - t.Errorf("no error should happend when deleting language, but got %v", err) + t.Errorf("no error should happened when deleting language, but got %v", err) } AssertAssociationCount(t, users, "Languages", 4, "after delete") if err := DB.Model(&users).Association("Languages").Delete(users[0].Languages[0], users[1].Languages[1]); err != nil { - t.Errorf("no error should happend when deleting language, but got %v", err) + t.Errorf("no error should happened when deleting language, but got %v", err) } AssertAssociationCount(t, users, "Languages", 2, "after delete") @@ -282,13 +282,13 @@ func TestSingleTableMany2ManyAssociationForSlice(t *testing.T) { // Delete if err := DB.Model(&users).Association("Team").Delete(&users[2].Team); err != nil { - t.Errorf("no error should happend when deleting team, but got %v", err) + t.Errorf("no error should happened when deleting team, but got %v", err) } AssertAssociationCount(t, users, "Team", 4, "after delete") if err := DB.Model(&users).Association("Team").Delete(users[0].Team[0], users[1].Team[1]); err != nil { - t.Errorf("no error should happend when deleting team, but got %v", err) + t.Errorf("no error should happened when deleting team, but got %v", err) } AssertAssociationCount(t, users, "Team", 2, "after delete") diff --git a/tests/migrate_test.go b/tests/migrate_test.go index 5293898f..194b5cbf 100644 --- a/tests/migrate_test.go +++ b/tests/migrate_test.go @@ -131,7 +131,7 @@ func TestColumns(t *testing.T) { } if err := DB.Table("column_structs").Migrator().AlterColumn(&ColumnStruct2{}, "Name"); err != nil { - t.Fatalf("no error should happend when alter column, but got %v", err) + t.Fatalf("no error should happened when alter column, but got %v", err) } if columnTypes, err := DB.Migrator().ColumnTypes(&ColumnStruct{}); err != nil { diff --git a/tests/scanner_valuer_test.go b/tests/scanner_valuer_test.go index 7d72db15..ec228f00 100644 --- a/tests/scanner_valuer_test.go +++ b/tests/scanner_valuer_test.go @@ -38,7 +38,7 @@ func TestScannerValuer(t *testing.T) { } if err := DB.Create(&data).Error; err != nil { - t.Errorf("No error should happend when create scanner valuer struct, but got %v", err) + t.Errorf("No error should happened when create scanner valuer struct, but got %v", err) } var result ScannerValuerStruct