aconfig
aconfig copied to clipboard
Feature Request: support any type that implements Setter (or any other similar) interface
Hello, thank you for a great library!
Sometimes there is a need to pass as an ENV variable, not a single value, but a whole struct to override all the fields inside the struct at once. This might probably be needed in highly configurable applications, where the number of exposed config params is big enough. To solve this issue generically, the lib can give developers the ability to set a custom Unmarshaler/Setter for a type.
A typical interface to support this feature might look like this:
type Setter interface {
SetValue(string) error
}
Examples from other libs:
- https://github.com/kelseyhightower/envconfig#custom-decoders
- https://github.com/ilyakaznacheev/cleanenv#supported-types
Also, please add a README.md section with information about supported data types/struct tags. Like in the: https://github.com/kelseyhightower/envconfig#supported-struct-field-types
Thanks, will take a look shortly.