Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to specfy a map of slices? #409

Open
nf-brentsaner opened this issue Jul 15, 2024 · 0 comments
Open

How to specfy a map of slices? #409

nf-brentsaner opened this issue Jul 15, 2024 · 0 comments

Comments

@nf-brentsaner
Copy link

Given a struct field of type map[string][]string and env tag of SOMEVAR, how can one specify pairs in the environment variable?

I recommend use of a semicolon. e.g.:

export SOMEVAR='foo1:bar1,bar2;foo2:bar3;foo1:bar4'

should result in:

map[string][]string{
	"foo1": []string{
		"bar1",
		"bar2",
		"bar4",
	},
	"foo2": []string{
		"bar3",
	},
}

Currently, it would result in:

map[string][]string{
	"foo1": []string{
		"bar1,bar2;foo2:bar3;foo1:bar4",
	},
}

Likewise, specifying (assuming short:"m"):

-m "foo1:bar1,bar2" -m "foo2:bar3,bar4" -m "foo1:bar5"

currently would result in:

map[string][]string{
	"foo1": []string{
		"bar5",
	},
	"foo2": []string{
		"bar3,bar4",
	},
}

instead of:

map[string][]string{
	"foo1": []string{
		"bar1",
		"bar2",
		"bar5",
	},
	"foo2": []string{
		"bar3",
		"bar4",
	},
}

Which is also clearly incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant