as the spec of golang, I try to write test code. as the spec says, the init order is d,b,c,a, I think the b should be 4 and c should be 5, but I got b == 5 and c == 4 is there something wrong? or I misunderstand the spec?
I tried in go version as below
go version go1.12.4 linux/amd64
package main
import "fmt"
var (
a = c + b
b = f()
c = f()
d = 3
)
func f() int {
d++
return d
}
func main() {
fmt.Println("a", a)
fmt.Println("b", b)
fmt.Println("c", c)
fmt.Println("d", d)
}
the result is
result:
a 9
b 5
c 4
d 5
expect b = 4, c = 5