Slice support
I would like to be able to define slices of data in my environment, and not have to do the extra work of processing the string into a slice after the env unmarshalling process.
An example use case would be defining BCC email addresses:
// env
[email protected]|[email protected]|[email protected]
// settings.go
type Settings struct {
BCC []string `env:"BCC_EMAILS"`
}
Since this just piggy-backs off the existing type conversion process, slices of all supported types will also be supported.
Hi @jimmykodes, I'm not sure about mixing commas for structtags delimiting and support for slice. Perhaps make the delimiter a parameter but I'm not sure how it will look.
hey @hinshun been awhile since i've looked at this 😬 picking it back up again though.
I've removed the "overloading" of the commas here and made the separator configurable by an environment variable. There may need to be some extra gymnastics to support that coming from the env set rather than a call to the os.Getenv, which i'm happy to go through if you'd like, and if this solution is a little more to your liking.