forked from ogier/pflag
-
Notifications
You must be signed in to change notification settings - Fork 357
Open
Description
Since Go maps have randomized iteration order, FlagUsages()
returns inconsistent output:
// You can edit this code!
// Click here and start typing.
package main
import (
"fmt"
"github.com/spf13/pflag"
)
func main() {
counter := map[string]int{}
for i := 0; i < 100; i++ {
fs := pflag.NewFlagSet("t", pflag.ExitOnError)
fs.StringToString("foo", map[string]string{"a": "b", "c": "d"}, "usage")
output := fs.FlagUsages()
counter[output]++
}
fmt.Print(counter)
}
map[ --foo stringToString usage (default [a=b,c=d])
:88 --foo stringToString usage (default [c=d,a=b])
:12]
In projects with a workflow that writes the command usage to a file (e.g. README), this causes unnecessary diff all the time.
twz123
Metadata
Metadata
Assignees
Labels
No labels