LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 Package fmt implements formatted I/O with functions analogous | 6 Package fmt implements formatted I/O with functions analogous |
7 to C's printf and scanf. The format 'verbs' are derived from C's but | 7 to C's printf and scanf. The format 'verbs' are derived from C's but |
8 are simpler. | 8 are simpler. |
9 | 9 |
10 Printing: | 10 Printing: |
11 | 11 |
12 The verbs: | 12 The verbs: |
13 | 13 |
14 General: | 14 General: |
15 %v the value in a default format. | 15 %v the value in a default format. |
16 when printing structs, the plus flag (%+v) adds field na
mes | 16 when printing structs, the plus flag (%+v) adds field na
mes |
17 %#v a Go-syntax representation of the value | 17 %#v a Go-syntax representation of the value |
18 %T a Go-syntax representation of the type of the value | 18 %T a Go-syntax representation of the type of the value |
19 | 19 |
20 Boolean: | 20 Boolean: |
21 %t the word true or false | 21 %t the word true or false |
22 Integer: | 22 Integer: |
23 %b base 2 | 23 %b base 2 |
24 %c the character represented by the corresponding Unicode c
ode point | 24 %c the character represented by the corresponding Unicode c
ode point |
25 %d base 10 | 25 %d base 10 |
26 %o base 8 | 26 %o base 8 |
27 %x base 16, with lower-case letters for a-f | 27 %x base 16, with lower-case letters for a-f |
28 %X base 16, with upper-case letters for A-F | 28 %X base 16, with upper-case letters for A-F |
29 » » %U unicode format: U+1234; same as "U+%x" with 4 digits defau
lt | 29 » » %U» unicode format: U+1234; same as "U+%x" with 4 digits def
ault |
30 Floating-point and complex constituents: | 30 Floating-point and complex constituents: |
31 %e scientific notation, e.g. -1234.456e+78 | 31 %e scientific notation, e.g. -1234.456e+78 |
32 %E scientific notation, e.g. -1234.456E+78 | 32 %E scientific notation, e.g. -1234.456E+78 |
33 %f decimal point but no exponent, e.g. 123.456 | 33 %f decimal point but no exponent, e.g. 123.456 |
34 %g whichever of %e or %f produces more compact output | 34 %g whichever of %e or %f produces more compact output |
35 %G whichever of %E or %f produces more compact output | 35 %G whichever of %E or %f produces more compact output |
36 String and slice of bytes: | 36 String and slice of bytes: |
37 %s the uninterpreted bytes of the string or slice | 37 %s the uninterpreted bytes of the string or slice |
38 %q a double-quoted string safely escaped with Go syntax | 38 %q a double-quoted string safely escaped with Go syntax |
39 %x base 16 notation with two characters per byte | 39 %x base 16 notation with two characters per byte |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 Note: Fscan etc. can read one character (rune) past the | 154 Note: Fscan etc. can read one character (rune) past the |
155 input they return, which means that a loop calling a scan | 155 input they return, which means that a loop calling a scan |
156 routine may skip some of the input. This is usually a | 156 routine may skip some of the input. This is usually a |
157 problem only when there is no space between input values. | 157 problem only when there is no space between input values. |
158 However, if the reader provided to Fscan implements UnreadRune, | 158 However, if the reader provided to Fscan implements UnreadRune, |
159 that method will be used to save the character and successive | 159 that method will be used to save the character and successive |
160 calls will not lose data. To attach an UnreadRune method | 160 calls will not lose data. To attach an UnreadRune method |
161 to a reader without that capability, use bufio.NewReader. | 161 to a reader without that capability, use bufio.NewReader. |
162 */ | 162 */ |
163 package fmt | 163 package fmt |
LEFT | RIGHT |