From 56f8eca41dee4db98dc22bfa16b6993ec4e4ef9c Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Wed, 12 Apr 2023 21:57:00 +0530 Subject: [PATCH] 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. --- koanf.go | 1 - 1 file changed, 1 deletion(-) diff --git a/koanf.go b/koanf.go index 70d872df..8e575de8 100644 --- a/koanf.go +++ b/koanf.go @@ -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,