kelseyhightower / envconfig

Golang library for managing configuration data from environment variables
MIT License
5.01k stars 377 forks source link

add support for custom delimiters in map/slices #184

Open bsdlp opened 3 years ago

bsdlp commented 3 years ago

hey @kelseyhightower @teepark i think this would be a pretty valuable addition to this library (which i use a ton, thank you so much for your hard work).

use case for me personally is setting a env config that's a map of service name to host:port. with existing map support the delimiter : would cause this use case to not be supported

export SERVERS="hypixel;mc.hypixel.net:25565,sep;mc.sep.gg:25565"
type Config struct {
    DiscordToken        string   `required:"true"`
    DiscordWebhookId    string   `required:"true"`
    DiscordWebhookToken string   `required:"true"`
    ImgurClientId       string   `required:"true"`
    Servers             map[string]string `kv_delimiter:";" required:"true"`
}
smoya commented 3 years ago

It would be awesome if we can merge this PR as I am also facing this issue. Thanks, folks!

gregbarasch commented 2 years ago

@kelseyhightower @UnAfraid @dloukadakis Been a while -- this would be really cool to merge!

prusnak commented 2 years ago

go-envconfig can override separator via separator keyword: https://github.com/sethvargo/go-envconfig#separator

axilis-marko commented 1 year ago

Are there plans on merging this?

mminklet commented 1 year ago

Could this be merged? This has proven to be a blocker for my use case