Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Native support for map[string][]string? #398

@nsimons

Description

@nsimons

My scenario:

With the following env: MAP_STRING_TO_STRINGS="foo:bar,foo:baz"
I want to parse it into the following: map[foo:[bar baz]]

So something like this:

type Config struct {
  MyMapOfSlices map[string][]string 'env:"MAP_STRING_TO_STRINGS" envSeparator:"," envKeyValSeparator:":"'
}

The solution that I'm using now is to first parse it into a string slice and then manually for each item I split the string at the separator and build my own map. Would it make sense to add this functionality natively in caarlos0/env instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions