Repository navigation
fix(read): parse env in StringMap for map[string]string values - #232
Merged
Merged
Conversation
StringMap parsed env for map values decoded from files, but returned a
map[string]string stored by Set or LoadData as is, so with ParseEnv
${VAR} was left unexpanded. Clone and parse it like Strings does for
[]string since gookit#230.
inhere
added a commit
that referenced
this pull request
Oct 27, 2026
… paths - document the contract on StringMap like Strings does since c0ce4bb: with ParseEnv a parsed copy is returned, otherwise the stored map[string]string is returned directly, so the caller must not change it. - cover the two paths the #232 test left out: the read cache returns the parsed map on the second call, and a map[string]string value from LoadData is parsed too. All of them fail on the code before #232.
inhere
added a commit
that referenced
this pull request
Oct 27, 2026
Ints and IntMap handed the raw elem/value to mathutil.ToInt, so with ParseEnv a
"${PORT}" elem failed with "cannot convert to int", while the scalar Int, Uint,
Float and Bool read the env value through getString. Strings (#230) and StringMap
(#232) already parse env for their string elem/value, so this was the last of the
group.
- parse a string elem/value with ParseEnvValue before the conversion, through the
new parseEnvValue helper; parseEnvString is a thin wrapper of it now.
- Ints accepts a []string value from Set, and IntMap a map[string]string one, which
returned the "value cannot be convert" error before.
- with ParseEnv off nothing is parsed, the conversions are the same as before.
Tests: the four value shapes ([]any, []string, map[string]any, map[string]string)
with ParseEnv on, plus the no-env branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
ParseEnv,StringMapparses env for map values decoded from files (themap[string]anyandmap[any]anybranches), but returns amap[string]stringstored bySetorLoadDataas is. #230 fixed the same gap for[]stringinStrings.This clones and parses the map the same way the
[]stringbranch ofStringsdoes, so the stored value is not changed; withParseEnvoff the stored map is returned as before. The new test fails without the change.go test -race ./...andgo vetpass locally (Go 1.26, withNAMEunset:TestIssues_114reads${NAME | Bob}and my shell setsNAME).Written with AI assistance (Claude); I have reviewed the change.