Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to ErrorUnused is Impractical #307

Open
dmullis opened this issue Jul 17, 2024 · 2 comments
Open

Access to ErrorUnused is Impractical #307

dmullis opened this issue Jul 17, 2024 · 2 comments

Comments

@dmullis
Copy link

dmullis commented Jul 17, 2024

Referring to #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:

  1. As seen in the excerpt below, if arg c.DecoderConfig is set to non-nil, 'o' is ignored; the caller must instead pass in a pointer through the Result field.
  2. The above is undocumented, users must download and read the koanf source.
  3. The comment's reference to mitchellh/mapstructure is stale; a newer fork is now linked in, and must be located to obtain authoritative info on the semantics of ErrorUnused.
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-

@knadh
Copy link
Owner

knadh commented Jul 21, 2024

Could you please send a PR? About mapstructure, please see: #262

@optician
Copy link

I believe it should be changed in the underlying library. Because the problem is mixing of config params and a result 'container' in DecoderConfig.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants