1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| package main import ( "fmt" "os" ) type point struct { x, y int } func main() { p := point{1, 2} fmt.Printf("%v\n", p) fmt.Printf("%+v\n", p) fmt.Printf("%#v\n", p) fmt.Printf("%T\n", p) fmt.Printf("%p\n", &p) fmt.Printf("%#p\n", &p) fmt.Printf("%t\n", true) fmt.Printf("%d\n", 123) fmt.Printf("%+d\n", 123) fmt.Printf("%b\n", 14) fmt.Printf("%o\n", 16) fmt.Printf("%#o\n", 16) fmt.Printf("%c\n", 33) fmt.Printf("%x\n", 456) fmt.Printf("%X\n", 456) fmt.Printf("%#x\n", 456) fmt.Printf("%f\n", 78.9) fmt.Printf("%e\n", 123400000.0) fmt.Printf("%E\n", 123400000.0) fmt.Printf("%s\n", "\"string\"") fmt.Printf("%q\n", "\"string\"") fmt.Printf("%#q\n", "string") fmt.Printf("%x\n", "hex this") fmt.Printf("|%6d|%6d|\n", 12, 345) fmt.Printf("|%6.2f|%6.2f|\n", 1.2, 3.45) fmt.Printf("%g\n", 1.23) fmt.Printf("%.3g\n", 12.34) fmt.Printf("|%-6.3f|%-6.2f|\n", 1.2, 3.45) fmt.Printf("%05d\n", 43) fmt.Printf("|%6s|%6s|\n", "foo", "b") fmt.Printf("|%-6s|%-6s|\n", "foo", "b") s := fmt.Sprintf("a %s", "string") fmt.Println(s) fmt.Fprintf(os.Stderr, "an %s\n", "error") }
|