When setting a count flag, the default value setting is not supported -- FlagSet.CountVarP() or FlagSet.CountVar() only takes name and usage as parameters. Weirdly, it is noted in the comment that default value is allowed.
IMHO, the only way to preserve a backard compatibility would be to extend these methods with some ...Option parameter. One such option could support adding a default value.
When setting a count flag, the default value setting is not supported --
FlagSet.CountVarP()
orFlagSet.CountVar()
only takesname
andusage
as parameters. Weirdly, it is noted in the comment that default value is allowed.https://github.com/spf13/pflag/blob/d5e0c0615acee7028e1e2740a11102313be88de1/count.go#L47-L58