knadh / koanf

Simple, extremely lightweight, extensible, configuration management library for Go. Support for JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Discuss: return `error` for ` Provider(cfg Config)`

missedone opened this issue · comments

@knadh i'd like to discuss the API change

almost all the provider func returns the object without error

example:

func Provider(cfg Config) *Vault {
...
}

I'm thinking of returning an error along with provider object:

func Provider(cfg Config) (*Vault, error) {
...
}

i think the original func signature support the inline the Provider instantiation within k.Load(...), but for Vault, S3 and other providers relies on the external system, it pretty much return nil if something wrong in the config or network, etc.
hence a panic threw out and the app process gets exit.

it's not very friendly to diagnose the issue.

Yes, indeed. We can do a v2 release for the provider to accommodate the breaking change.