koanf
koanf copied to clipboard
Access to ErrorUnused is Impractical
Referring to https://github.com/knadh/koanf/issues/189:
What bothers me with this solution is that I have to take the copy paste the default configuration chosen by koanf into my code and tweak it locally.
As a user of the API, this is one of several associated bugs I tripped over. The others being:
- As seen in the excerpt below, if arg
c.DecoderConfigis set to non-nil,'o'is ignored; the caller must instead pass in a pointer through theResultfield. - The above is undocumented, users must download and read the
koanfsource. - The comment's reference to
mitchellh/mapstructureis stale; a newer fork is now linked in, and must be located to obtain authoritative info on the semantics ofErrorUnused.
koanf.go-// UnmarshalWithConf is like Unmarshal but takes configuration params in UnmarshalConf.
koanf.go-// See mitchellh/mapstructure's DecoderConfig for advanced customization
koanf.go-// of the unmarshal behaviour.
koanf.go-func (ko *Koanf) UnmarshalWithConf(path string, o interface{}, c UnmarshalConf) error {
koanf.go- if c.DecoderConfig == nil {
koanf.go: c.DecoderConfig = &mapstructure.DecoderConfig{
koanf.go- DecodeHook: mapstructure.ComposeDecodeHookFunc(
koanf.go- mapstructure.StringToTimeDurationHookFunc(),
koanf.go- textUnmarshalerHookFunc()),
koanf.go- Metadata: nil,
koanf.go- Result: o,
koanf.go- WeaklyTypedInput: true,
koanf.go- }
koanf.go- }
koanf.go-
Could you please send a PR? About mapstructure, please see: https://github.com/knadh/koanf/issues/262
I believe it should be changed in the underlying library. Because the problem is mixing of config params and a result 'container' in DecoderConfig.