Repository navigation
Preserve trailing whitespace in StringToString formatting - #522
Merged
tomasaschan merged 1 commit intoOct 19, 2026
Merged
Conversation
tomasaschan
approved these changes
Oct 19, 2026
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.
StringToStringformats its map with a CSV writer, then appliesstrings.TrimSpaceto the result. That removes data from an unquoted final value: a default or explicitly setkey=valueis displayed as[key=value], and a whitespace-only value is displayed as empty. This also affects the default representation captured when a flag is registered.Remove only the single newline appended by the CSV writer, matching the existing
writeAsCSVhelper. Keep spaces, tabs and Unicode whitespace that belong to the value.Add eight table-driven cases, each exercised with a default map and an explicitly set value. They cover trailing spaces, tabs, a nonbreaking space, a whitespace-only value, ordinary/empty values, and CSV-quoted comma/newline controls. The four unquoted whitespace cases fail in both modes before the fix; all pass afterward.
Validation on Windows with Go 1.27.2 and Clang 23.1.3:
go test -race -count=1 ./...: passed.go vet ./...: passed.golangci-lint2.14.0 with the repository configuration: zero issues on a clean LF checkout of the published commit. The initial Windows CRLF checkout produced formatter-only failures in unchanged files; no unrelated formatting changes are included.gofmtandgit diff --check: passed.The change uses
strings.TrimSuffix, already used by the repository and available under its Go 1.12 baseline. No new dependency or parsing behavior is introduced.