...
1 package main
2
3 import "fmt"
4
5
6
7 var counter int
8
9 func next() int {
10 c := counter
11 counter++
12 return c
13 }
14
15 func next2() (x int, y int) {
16 x = next()
17 y = next()
18 return
19 }
20
21 func makeOrder() int {
22 _, _, _, _ = f, b, d, e
23 return 0
24 }
25
26 func main() {
27
28
29
30
31
32 abcdef := [6]int{a, b, c, d, e, f}
33 if abcdef != [6]int{0, 1, 2, 3, 4, 5} {
34 panic(abcdef)
35 }
36
37
38 if g != 1 {
39 panic(g)
40 }
41 }
42
43 var order = makeOrder()
44
45 var a, b = next(), next()
46 var c, d = next2()
47 var e, f = next(), next()
48
49 var (
50 g int
51 _ = func() int { g = 1; return 0 }()
52 )
53
54
55
56 var order2 []string
57
58 func create(x int, name string) int {
59 order2 = append(order2, name)
60 return x
61 }
62
63 var C = create(B+1, "C")
64 var A, B = create(1, "A"), create(2, "B")
65
66
67 func init() {
68 x := fmt.Sprint(order2)
69
70 if x != "[B C A]" &&
71 x != "[A B C]" {
72 panic(x)
73 }
74 if C != 3 {
75 panic(c)
76 }
77 }
78
View as plain text