Skip to content

fix(flags): preserve integer map key brackets - #528

Open
terminalchai wants to merge 1 commit into
spf13:masterfrom
terminalchai:fix/integer-map-bracket-keys
Open

terminalchai wants to merge 1 commit into
spf13:masterfrom
terminalchai:fix/integer-map-bracket-keys

Conversation

@terminalchai

Copy link
Copy Markdown

GetStringToInt and GetStringToInt64 round-trip values through their bracket-wrapped String() representation. The converters currently use strings.Trim(val, "[]"), which also removes brackets belonging to the first key: a stored key "[name]" comes back as "name]".

Remove only one leading and trailing wrapper bracket in each converter. Regression tests cover both public getters with defaults, explicit and repeated Set calls, bracketed/empty/ordinary keys, multiple entries, and integer limits. The tests fail against the original converters and pass with the fix.

Related to #413's bracket-stripping problem, but this change is limited to integer-map getters. #414 handles StringToString, and #515's integer-map sorting change is independent.

Full tests, race tests, Windows 386 tests, vet, build, and changed-file formatting pass on Go 1.26.1. golangci-lint 2.15.0 reports zero new issues; its full run reports three pre-existing gofmt findings in unchanged bool.go, bool_func.go, and bool_slice.go, reproduced on pristine upstream d26a4dc.

Prepared with AI assistance and separate specification and code reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant