Skip to content

Commit e1c978b

Browse files
Serabemcuadros
authored andcommitted
Delete some lines of code in filler (#6)
There was a few cases inside `isEmpty` where a boolean hardcode value was being returned only if the value was not considered empty. This change make all the cases return in both cases, leaving the final value as a default case.
1 parent 19ec14a commit e1c978b

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

filler.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,13 @@ func (f *Filler) SetDefaultValues(fields []*FieldData) {
6969
func (f *Filler) isEmpty(field *FieldData) bool {
7070
switch field.Value.Kind() {
7171
case reflect.Bool:
72-
if field.Value.Bool() != false {
73-
return false
74-
}
72+
return !field.Value.Bool()
7573
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
76-
if field.Value.Int() != 0 {
77-
return false
78-
}
74+
return field.Value.Int() == 0
7975
case reflect.Float32, reflect.Float64:
80-
if field.Value.Float() != .0 {
81-
return false
82-
}
76+
return field.Value.Float() == .0
8377
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
84-
if field.Value.Uint() != 0 {
85-
return false
86-
}
78+
return field.Value.Uint() == 0
8779
case reflect.Slice:
8880
switch field.Value.Type().Elem().Kind() {
8981
case reflect.Struct:
@@ -94,11 +86,8 @@ func (f *Filler) isEmpty(field *FieldData) bool {
9486
return field.Value.Len() == 0
9587
}
9688
case reflect.String:
97-
if field.Value.String() != "" {
98-
return false
99-
}
89+
return field.Value.String() == ""
10090
}
101-
10291
return true
10392
}
10493

0 commit comments

Comments
 (0)