Skip to content

Commit 56f8eca

Browse files
committed
Remove buggy mapstructure.StringToSliceHookFunc(",").
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.
1 parent 98b36ee commit 56f8eca

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

koanf.go

-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ func (ko *Koanf) UnmarshalWithConf(path string, o interface{}, c UnmarshalConf)
252252
c.DecoderConfig = &mapstructure.DecoderConfig{
253253
DecodeHook: mapstructure.ComposeDecodeHookFunc(
254254
mapstructure.StringToTimeDurationHookFunc(),
255-
mapstructure.StringToSliceHookFunc(","),
256255
textUnmarshalerHookFunc()),
257256
Metadata: nil,
258257
Result: o,

0 commit comments

Comments
 (0)