Repository navigation
fix: expand environment variables in string slices - #230
Merged
inhere merged 1 commit intoOct 26, 2026
Merged
Conversation
inhere
added a commit
that referenced
this pull request
Oct 26, 2026
…t the contract Follow up of #230: - rename Config.stringValue() to parseEnvString(), and document what it does - document the Strings() contract: with ParseEnv the string elems are parsed and a copy is returned, otherwise the []string value of the config data may be returned as is - note in TestStringsParseEnvCache that a cache hit keeps the value expanded on the first read (the same as the String() cache), it is not a missed invalidation - drop a dead comment line in the []any branch
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.
Stringsskipped environment expansion for slice elementsI apply
ParseEnvto string elements in both supported slice types, preserve raw data, and keep existing conversion and cache behavior