fix: preserve brackets in integer map keys - #509
Open
mehuljariwala wants to merge 1 commit into
Open
Conversation
tomasaschan
reviewed
Sep 6, 2026
tomasaschan
left a comment
Collaborator
There was a problem hiding this comment.
Nice, thanks!
This seems like it might affect the handling of the value of the flag too - is it worth adding a few test cases to the table to show what the behavior is when a value ends with a bracket?
It seems likely to me that behavior is either unchanged, or fixed, by this PR, and making the behavior explicitly test covered makes it easier to reason about whether it's correct.
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.
GetStringToIntandGetStringToInt64strip every leading and trailing square bracket from the formatted map. This removes brackets that belong to the first key: parsing--map=[key]=42stores[key], but the getter returnskey].Remove only the single surrounding pair emitted by
String(). Add table-driven regressions for bracketed keys, repeated opening brackets, a leading closing bracket, a brackets-only key, and an ordinary key. Each case checks the getter against the bound flag value.Both getters fail the new bracket cases before the fix. Afterward, the full
go test -race ./...,go vet ./..., andgolangci-lint runpass on Go 1.27.1 (macOS arm64). Changes use APIs available under the project's Go 1.12 baseline.Related to #413, but limited to the integer-valued map getters; the existing StringToString PRs are unaffected. Prepared with OpenAI Codex assistance, with the regression and validation commands executed locally.