caarlos0 / caarlos0/env

Native support for map[string][]string?

Open
#398 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
6.3k
Forks
284
Avg merge
1d 17h
Merged PRs (30d)
1

Description

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?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the environment-variable tag parsing and conversion entry points in caarlos0/env, then trace how maps and slices are currently handled. Add coverage for MAP_STRING_TO_STRINGS with comma and colon separators, and consider edge cases such as repeated keys; done means the tagged map[string][]string field receives both values without manual parsing.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.