aconfig icon indicating copy to clipboard operation
aconfig copied to clipboard

Feature Request: support any type that implements Setter (or any other similar) interface

Open skovtunenko opened this issue 1 year ago • 1 comments

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

skovtunenko avatar Jul 19 '22 12:07 skovtunenko

Thanks, will take a look shortly.

cristaloleg avatar Jul 19 '22 12:07 cristaloleg