diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e2ea89a7..370417fc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -84,7 +84,7 @@ jobs: matrix: dbversion: ['postgres:latest', 'postgres:11', 'postgres:10'] go: ['1.16', '1.15', '1.14'] - platform: [ubuntu-latest] # can not run in macOS and widnowsOS + platform: [ubuntu-latest] # can not run in macOS and Windows runs-on: ${{ matrix.platform }} services: diff --git a/errors.go b/errors.go index 3126b8e7..569207a6 100644 --- a/errors.go +++ b/errors.go @@ -33,8 +33,8 @@ var ( ErrEmptySlice = errors.New("empty slice found") // ErrDryRunModeUnsupported dry run mode unsupported ErrDryRunModeUnsupported = errors.New("dry run mode unsupported") - // ErrInvaildDB invalid db - ErrInvaildDB = errors.New("invalid db") + // ErrInvalidDB invalid db + ErrInvalidDB = errors.New("invalid db") // ErrInvalidValue invalid value ErrInvalidValue = errors.New("invalid value") // ErrInvalidValueOfLength invalid values do not match length diff --git a/gorm.go b/gorm.go index 0da218f6..e105a933 100644 --- a/gorm.go +++ b/gorm.go @@ -348,7 +348,7 @@ func (db *DB) DB() (*sql.DB, error) { return sqldb, nil } - return nil, ErrInvaildDB + return nil, ErrInvalidDB } func (db *DB) getInstance() *DB { diff --git a/logger/sql.go b/logger/sql.go index 4c5f92ed..3d31d23c 100644 --- a/logger/sql.go +++ b/logger/sql.go @@ -28,7 +28,7 @@ func isPrintable(s []byte) bool { return true } -var convertableTypes = []reflect.Type{reflect.TypeOf(time.Time{}), reflect.TypeOf(false), reflect.TypeOf([]byte{})} +var convertibleTypes = []reflect.Type{reflect.TypeOf(time.Time{}), reflect.TypeOf(false), reflect.TypeOf([]byte{})} func ExplainSQL(sql string, numericPlaceholder *regexp.Regexp, escaper string, avars ...interface{}) string { var convertParams func(interface{}, int) @@ -91,7 +91,7 @@ func ExplainSQL(sql string, numericPlaceholder *regexp.Regexp, escaper string, a } else if rv.Kind() == reflect.Ptr && !rv.IsZero() { convertParams(reflect.Indirect(rv).Interface(), idx) } else { - for _, t := range convertableTypes { + for _, t := range convertibleTypes { if rv.Type().ConvertibleTo(t) { convertParams(rv.Convert(t).Interface(), idx) return diff --git a/prepare_stmt.go b/prepare_stmt.go index 122e98d2..14570061 100644 --- a/prepare_stmt.go +++ b/prepare_stmt.go @@ -27,7 +27,7 @@ func (db *PreparedStmtDB) GetDBConn() (*sql.DB, error) { return sqldb, nil } - return nil, ErrInvaildDB + return nil, ErrInvalidDB } func (db *PreparedStmtDB) Close() { diff --git a/schema/naming.go b/schema/naming.go index 0643d1bd..1962c3c6 100644 --- a/schema/naming.go +++ b/schema/naming.go @@ -73,16 +73,16 @@ func (ns NamingStrategy) IndexName(table, column string) string { } func (ns NamingStrategy) formatName(prefix, table, name string) string { - formatedName := strings.Replace(fmt.Sprintf("%v_%v_%v", prefix, table, name), ".", "_", -1) + formattedName := strings.Replace(fmt.Sprintf("%v_%v_%v", prefix, table, name), ".", "_", -1) - if utf8.RuneCountInString(formatedName) > 64 { + if utf8.RuneCountInString(formattedName) > 64 { h := sha1.New() - h.Write([]byte(formatedName)) + h.Write([]byte(formattedName)) bs := h.Sum(nil) - formatedName = fmt.Sprintf("%v%v%v", prefix, table, name)[0:56] + string(bs)[:8] + formattedName = fmt.Sprintf("%v%v%v", prefix, table, name)[0:56] + string(bs)[:8] } - return formatedName + return formattedName } var ( diff --git a/schema/relationship.go b/schema/relationship.go index a8863bfe..061e9120 100644 --- a/schema/relationship.go +++ b/schema/relationship.go @@ -89,7 +89,7 @@ func (schema *Schema) parseRelation(field *Field) *Relationship { } if relation.Type == has { - // don't add relations to embeded schema, which might be shared + // don't add relations to embedded schema, which might be shared if relation.FieldSchema != relation.Schema && relation.Polymorphic == nil && field.OwnerSchema == nil { relation.FieldSchema.Relationships.Relations["_"+relation.Schema.Name+"_"+relation.Name] = relation } @@ -308,9 +308,9 @@ func (schema *Schema) buildMany2ManyRelation(relation *Relationship, field *Fiel f.Size = fieldsMap[f.Name].Size } relation.JoinTable.PrimaryFields = append(relation.JoinTable.PrimaryFields, f) - ownPriamryField := schema == fieldsMap[f.Name].Schema && ownFieldsMap[f.Name] + ownPrimaryField := schema == fieldsMap[f.Name].Schema && ownFieldsMap[f.Name] - if ownPriamryField { + if ownPrimaryField { joinRel := relation.JoinTable.Relationships.Relations[relName] joinRel.Field = relation.Field joinRel.References = append(joinRel.References, &Reference{ @@ -331,7 +331,7 @@ func (schema *Schema) buildMany2ManyRelation(relation *Relationship, field *Fiel relation.References = append(relation.References, &Reference{ PrimaryKey: fieldsMap[f.Name], ForeignKey: f, - OwnPrimaryKey: ownPriamryField, + OwnPrimaryKey: ownPrimaryField, }) } } diff --git a/schema/schema_helper_test.go b/schema/schema_helper_test.go index cc0306e0..6d2bc664 100644 --- a/schema/schema_helper_test.go +++ b/schema/schema_helper_test.go @@ -29,7 +29,7 @@ func checkSchema(t *testing.T, s *schema.Schema, v schema.Schema, primaryFields } if !found { - t.Errorf("schema %v failed to found priamry key: %v", s, field) + t.Errorf("schema %v failed to found primary key: %v", s, field) } } }) diff --git a/statement.go b/statement.go index 099c66d2..32bc462a 100644 --- a/statement.go +++ b/statement.go @@ -328,7 +328,7 @@ func (stmt *Statement) BuildCondition(query interface{}, args ...interface{}) [] } else if _, ok := v[key].(Valuer); ok { conds = append(conds, clause.Eq{Column: key, Value: v[key]}) } else { - // optimize relect value length + // optimize reflect value length valueLen := reflectValue.Len() values := make([]interface{}, valueLen) for i := 0; i < valueLen; i++ { @@ -398,7 +398,7 @@ func (stmt *Statement) BuildCondition(query interface{}, args ...interface{}) [] if len(args) == 1 { switch reflectValue.Kind() { case reflect.Slice, reflect.Array: - // optimize relect value length + // optimize reflect value length valueLen := reflectValue.Len() values := make([]interface{}, valueLen) for i := 0; i < valueLen; i++ {