Repository navigation
Conversation
Accept map values that are slices using the existing envSeparator and envKeyValSeparator tags. Duplicate keys append an element instead of replacing the slice. A FuncMap parser registered for the slice type keeps the previous last-value-wins behavior. Co-authored-by: SkinGap <SkipGip@users.noreply.github.com>
caarlos0
left a comment
There was a problem hiding this comment.
One correctness issue needs correction. Verification limits: this head has no reported CI checks or commit statuses. No local builds or tests were run; this review used static analysis and both required independent checks.
– Copilot, on behalf of Carlos
| elemParserFunc, ok := funcMap[sliceElemType] | ||
| if !ok { | ||
| elemParserFunc, ok = defaultBuiltInParsers[sliceElemType.Kind()] |
There was a problem hiding this comment.
[P2] Honor TextUnmarshaler before selecting the element parser
The new slice-valued map path bypasses element UnmarshalText methods. With the existing LogLevel type from env_test.go, map[string][]LogLevel and input foo:debug select strconv.ParseInt because the underlying kind is int8, so a valid debug value fails. Conversely, foo:7 succeeds even though LogLevel.UnmarshalText rejects it. Ordinary []LogLevel fields honor this method first (handleSlice), and the supported-types documentation includes TextUnmarshaler. Apply the same precedence here before the FuncMap/built-in fallback, while retaining whole-slice custom-parser behavior. Add a regression test for duplicate debug/info values and rejection of numeric 7.
– Copilot, on behalf of Carlos
Summary
map[string][]stringparsing with existingenvSeparator/envKeyValSeparatorenvDefault; unset vars leave the field unchangedUseFieldNameByDefault, aurl.URLfield'sHostandPathare overwritten fromHOSTandPATH#440 / Values are not loaded from environment with SetDefaultsForZeroValuesOnly #364 / Do not support pointer to user type #385 / Option to allow setting empty values #406 workTest plan
go test ./...go test -race ./...Closes #398
Related: volunteering on #407