Skip to content

Commit

Permalink
Flatten(): type-check input only once
Browse files Browse the repository at this point in the history
  • Loading branch information
Al2Klimov committed Mar 25, 2024
1 parent 10afc56 commit 365f97d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/flatten/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ func Flatten(value interface{}, prefix string) map[string]types.String {
for i, v := range value {
flatten(key+"["+strconv.Itoa(i)+"]", v)
}
case nil:
flattened[key] = types.MakeString("null")
default:
val := "null"
if value != nil {
val = fmt.Sprintf("%v", value)
}
flattened[key] = types.MakeString(val)
flattened[key] = types.MakeString(fmt.Sprintf("%v", value))
}
}

Expand Down

0 comments on commit 365f97d

Please sign in to comment.