support complex map types, where the map value can be a struct
- Dominant language
- Go
- Stars
- 6.3k
- Forks
- 284
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 1
Description
The proposal is to support complex map types so that we could do the following
```
type Test struct {
Str string `env:"DAT_STR"`
Num int `env:"DAT_NUM"`
}
type ComplexConfig struct {
Bar map[string]Test `envPrefix:"BAR_"`
}
t.Setenv("BAR_KEY1_DAT_STR", "b1t")
t.Setenv("BAR_KEY1_DAT_NUM", "201")
```
This is similar to https://github.com/caarlos0/env/issues/298 but for maps
The key can be any supported value (that are already present in either `opts.FuncMap` or the default parser list in `defaultBuiltInParsers`).
I will open a PR for this Issue.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the existing map handling and the parser paths named in the issue: opts.FuncMap and defaultBuiltInParsers. Implement support for map values that are structs, including envPrefix-based nested fields and supported key types, then verify the provided ComplexConfig example and related parsing behavior.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100