From 2d5cb997ed4d0e8f53fa1662111ad2cb053caf9c Mon Sep 17 00:00:00 2001 From: Jin Date: Sun, 20 Mar 2022 09:02:45 +0800 Subject: [PATCH] style: fix linter check for NamingStrategy and onConflictOption (#5174) --- callbacks/associations.go | 4 ++-- schema/naming.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/callbacks/associations.go b/callbacks/associations.go index 3b204ab6..644ef185 100644 --- a/callbacks/associations.go +++ b/callbacks/associations.go @@ -323,7 +323,7 @@ func SaveAfterAssociations(create bool) func(db *gorm.DB) { } } -func onConflictOption(stmt *gorm.Statement, s *schema.Schema, selectColumns map[string]bool, restricted bool, defaultUpdatingColumns []string) (onConflict clause.OnConflict) { +func onConflictOption(stmt *gorm.Statement, s *schema.Schema, defaultUpdatingColumns []string) (onConflict clause.OnConflict) { if len(defaultUpdatingColumns) > 0 || stmt.DB.FullSaveAssociations { onConflict.Columns = make([]clause.Column, 0, len(s.PrimaryFieldDBNames)) for _, dbName := range s.PrimaryFieldDBNames { @@ -349,7 +349,7 @@ func saveAssociations(db *gorm.DB, rel *schema.Relationship, rValues reflect.Val var ( selects, omits []string - onConflict = onConflictOption(db.Statement, rel.FieldSchema, selectColumns, restricted, defaultUpdatingColumns) + onConflict = onConflictOption(db.Statement, rel.FieldSchema, defaultUpdatingColumns) refName = rel.Name + "." values = rValues.Interface() ) diff --git a/schema/naming.go b/schema/naming.go index 47a2b363..a258beed 100644 --- a/schema/naming.go +++ b/schema/naming.go @@ -85,9 +85,9 @@ func (ns NamingStrategy) IndexName(table, column string) string { } func (ns NamingStrategy) formatName(prefix, table, name string) string { - formattedName := strings.Replace(strings.Join([]string{ + formattedName := strings.ReplaceAll(strings.Join([]string{ prefix, table, name, - }, "_"), ".", "_", -1) + }, "_"), ".", "_") if utf8.RuneCountInString(formattedName) > 64 { h := sha1.New()