Go offers several verbs that are passed to printing functions to format Go values. In this appendix, we present the most known verbs and special values that can be passed to these functions. You can refer to these tables throughout the book. The results for each of the following entries were generated by fmt.Printf("{Verb}",
value)
.
Table B.1 Default
Verb |
Output for fmt.Printf("{Verb}", []int64{0, 1}) |
Description |
|
|
Default format |
|
|
Go-syntax format |
|
|
Type of the value |
Table B.3 Floats
Verb |
Output for fmt.Printf("{Verb}", 123.456) |
Description |
|
|
Scientific notation |
|
|
Decimal point, no exponent. The default precision is 6. |
|
|
Default width, precision 2 digits after the decimal point |
|
␣␣ |
Width 8 chars, precision 2 digits after the decimal point. Default padding character is space. |
|
|
Width 8 chars, precision 2 digits after the decimal point. Left padding with specified character (here, 0). |
|
|
Exponent when needed, necessary digits only |