Format Strings

When specifying the format string for printf or conv.format, there are a number of options you can use to configure how the resulting string will be formatted. Format specifiers are specified between curly-braces ({}) in the format string. There is a one-to-one mapping between the number of curly-braces and arguments provided to conv.format, at least at the moment.

This table provides brief defintions as to what can appear between the curly braces.

*If the variable is a pointer, dereference the pointer and format the result
pPretty formatting
.NSets the decimal precision when formatting a float to be N digits
bNSets the base when formatting an interger to be N
xShorthand for b16
wNLeft-pad to N characters long (this might not work for everything)
"Quote strings in double quotes. Quotes are only added to strs
'Quote string in single quotes. Quotes are only added to strs
dDisable printing enums as strings and print as numbers instead