Repository navigation
Print StringToInt and StringToInt64 defaults in sorted order - #515
Open
SulimanAbdulrazzaq wants to merge 1 commit into
Open
SulimanAbdulrazzaq wants to merge 1 commit into
SulimanAbdulrazzaq wants to merge 1 commit into
Conversation
spf13#365 sorted the keys in stringToStringValue.String() so that the "(default [...])" text in FlagUsages no longer changes from run to run (spf13#362). The stringToInt and stringToInt64 values still range over the map directly, so a flag with more than one default key prints them in Go's randomized map order and --help output, or docs generated from it, differs between runs. Sort the keys in both String() methods the same way.
|
|
Author
|
@tomasaschan when you have a moment, could one of you approve the workflow runs and take a look at this one? No checks have run on the current head yet. |
Collaborator
|
The influx of PRs, especially automated ones, to this repo has been big enough that I have stopped interacting with any PRs that don't show the CLA is signed. Do that, and it gets on the review queue. |
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.
#365 made
stringToStringValue.String()sort its keys, so aStringToStringflag's(default [...])text inFlagUsages()is stable between runs (#362).StringToIntandStringToInt64never got the same change. TheirString()methods still range over the map directly, so a flag with more than one default key prints them in Go's randomized map order:This is the problem #362 described:
--helpoutput, and any usage text or docs generated from it, changes on every run.This PR sorts the keys in both
String()methods, the same waystring_to_string.godoes.sort.Stringskeeps it compatible with the Go 1.12 job in CI.Tests
TestS2IUsageSortedandTestS2I64UsageSortedset up a four-key default and check, 100 times, thatString()returns[a=1,b=2,c=3,d=4]and thatFlagUsages()contains(default [a=1,b=2,c=3,d=4]).expected String() to be "[a=1,b=2,c=3,d=4]" but got: "[c=3,a=1,d=4,b=2]".go test -race -v ./....go vet ./...is clean andgofmtreports no changes.