Skip to content

Commit

Permalink
fix: additional check on flatType func to avoid crash
Browse files Browse the repository at this point in the history
  • Loading branch information
glcbrg committed Jan 12, 2024
1 parent be17ee8 commit 2fdb379
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion utils/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ func Md5File(filename string) (string, error) {
// FlatStruct tries to flat a struct object in a map[string]string
func FlatStruct(s interface{}) map[string]string {
flatten := make(map[string]string)
flatType(s, "", flatten)
if s != nil {
flatType(s, "", flatten)
}
return flatten
}

Expand All @@ -79,6 +81,9 @@ func flatType(s interface{}, prefix string, flatten map[string]string) {
if kind == reflect.Ptr || kind == reflect.Interface {
v = reflect.Indirect(v)
kind = v.Kind()
if kind == reflect.Invalid {
return
}
}
t := v.Type()

Expand Down

0 comments on commit 2fdb379

Please sign in to comment.