Skip to content

Commit

Permalink
Remove buggy mapstructure.StringToSliceHookFunc(",").
Browse files Browse the repository at this point in the history
The `StringToSliceHookFunc(",")` hook is supposed to decode a delim
separated string to a slice of strings. However, the hook only receives
`reflect.Kind` for the target field to determine its type. While it
should be a `[]string`, it can only tell if it's a slice,
thus triggering it for any slice type and failing. This breaks
the unmarshalling of strings to `[]byte` fields.
  • Loading branch information
knadh committed Apr 12, 2023
1 parent 98b36ee commit 56f8eca
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion koanf.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ func (ko *Koanf) UnmarshalWithConf(path string, o interface{}, c UnmarshalConf)
c.DecoderConfig = &mapstructure.DecoderConfig{
DecodeHook: mapstructure.ComposeDecodeHookFunc(
mapstructure.StringToTimeDurationHookFunc(),
mapstructure.StringToSliceHookFunc(","),
textUnmarshalerHookFunc()),
Metadata: nil,
Result: o,
Expand Down

0 comments on commit 56f8eca

Please sign in to comment.