1
2
3
4
5 package main
6
7 import (
8 "fmt"
9 "time"
10 )
11
12 func main() {
13 growstack()
14 test()
15 }
16
17
18 func id(x int) int {
19 return x
20 }
21
22 func test() {
23 x := id(0)
24 y := id(0)
25 fmt.Println(x)
26 for i := x; i < 3; i++ {
27 x := i * i
28 y += id(x)
29 }
30 y = x + y
31 fmt.Println(x, y)
32
33 for x := 0; x <= 1; x++ {
34 a := y
35 f1(a)
36 {
37 b := 0
38 f2(b)
39 if gretbool() {
40 c := 0
41 f3(c)
42 } else {
43 c := 1.1
44 f4(int(c))
45 }
46 f5(b)
47 }
48 f6(a)
49 }
50
51 {
52 var (
53 j = id(1)
54 f = id(2)
55 )
56 for i := 0; i <= 5; i++ {
57 j += j * (j ^ 3) / 100
58 if i == f {
59 fmt.Println("foo")
60 break
61 }
62 sleepytime()
63 }
64 helloworld()
65 }
66 }
67
68 func sleepytime() {
69 time.Sleep(5 * time.Millisecond)
70 }
71
72 func helloworld() {
73 fmt.Println("Hello, World!")
74 }
75
76
77 func f1(x int) {}
78
79
80 func f2(x int) {}
81
82
83 func f3(x int) {}
84
85
86 func f4(x int) {}
87
88
89 func f5(x int) {}
90
91
92 func f6(x int) {}
93
94 var boolvar = true
95
96 func gretbool() bool {
97 x := boolvar
98 boolvar = !boolvar
99 return x
100 }
101
102 var sink string
103
104
105 func growstack() {
106 sink = fmt.Sprintf("%#v,%#v,%#v", 1, true, "cat")
107 }
108
View as plain text