math/big: big.Int fmt.Formatter
implementation should support %q
#42022
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
I suggest a small quality-of-life improvement to the
*big.Int
type to support printing as a quoted string.*big.Int
implementsfmt.Formatter
and (contrary to the documentation) supports thes
verb, printing the integer in decimal format. This allows you to do:However, it does not support
q
, which becomes surprising for people accustomed to the special formatting considerations for string formats whereinq
is implicitly supported for types implementingfmt.Stringer
. Instead you have to explicitly call theString()
method:And if you forget?
https://play.golang.org/p/5YiBHW5djUM
I don't imagine there would be a big back-compat concern.
I'm happy to provide the code change if folks are on board.
The text was updated successfully, but these errors were encountered: