@@ -103,7 +103,8 @@ func validate(model interface{}, in map[string]bool, prefix string) *errors.Serv
103103 }
104104 field := reflectValue .Field (i ).Interface ()
105105 name := strings .Split (tag , "," )[0 ]
106- if kind == reflect .Struct {
106+ switch kind { //nolint:exhaustive // Only Struct and Slice need special handling, rest handled by default
107+ case reflect .Struct :
107108 if t .Type == reflect .TypeOf (& time.Time {}) {
108109 delete (in , name )
109110 } else {
@@ -116,12 +117,12 @@ func validate(model interface{}, in map[string]bool, prefix string) *errors.Serv
116117 }
117118 }
118119 }
119- } else if t . Type . Kind () == reflect .Slice {
120+ case reflect .Slice :
120121 // TODO: We don't support Slices' validation :(
121122 in = removeStar (in , name )
122123 continue
123- //_ = validate(slice, in, name)
124- } else {
124+ // _ = validate(slice, in, name)
125+ default :
125126 prefixedName := name
126127 if prefix != "" {
127128 prefixedName = fmt .Sprintf ("%s.%s" , prefix , name )
@@ -188,7 +189,8 @@ func structToMap(item interface{}, in map[string]bool, prefix string) map[string
188189 }
189190 field := reflectValue .Field (i ).Interface ()
190191 name := strings .Split (tag , "," )[0 ]
191- if kind == reflect .Struct {
192+ switch kind { //nolint:exhaustive // Only Struct and Slice need special handling, rest handled by default
193+ case reflect .Struct :
192194 if t .Type == reflect .TypeOf (& time.Time {}) {
193195 if _ , ok := in [name ]; ok {
194196 if timePtr , ok := field .(* time.Time ); ok && timePtr != nil {
@@ -205,7 +207,7 @@ func structToMap(item interface{}, in map[string]bool, prefix string) map[string
205207 res [name ] = subStruct
206208 }
207209 }
208- } else if kind == reflect .Slice {
210+ case reflect .Slice :
209211 s := reflect .ValueOf (field )
210212 if s .Len () > 0 {
211213 result := make ([]interface {}, 0 , s .Len ())
@@ -220,7 +222,7 @@ func structToMap(item interface{}, in map[string]bool, prefix string) map[string
220222 res [name ] = result
221223 }
222224 }
223- } else {
225+ default :
224226 prefixedName := name
225227 if prefix != "" {
226228 prefixedName = fmt .Sprintf ("%s.%s" , prefix , name )
0 commit comments