-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
I suggest a small quality-of-life improvement to the *big.Int type to support printing as a quoted string. *big.Int implements fmt.Formatter and (contrary to the documentation) supports the s verb, printing the integer in decimal format. This allows you to do:
fmt.Printf("My int: %s\n", big.NewInt(1))
However, it does not support q, which becomes surprising for people accustomed to the special formatting considerations for string formats wherein q is implicitly supported for types implementing fmt.Stringer. Instead you have to explicitly call the String() method:
fmt.Printf("My quoted int: %q\n", big.NewInt(1).String())
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.
lmittmann and mrwonko
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.