You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
}
got
result:
a 9
b 5
c 4
d 5
but with the order in spec d-> b -> c -> a, I think the expect result shoud be
a 9
b 4
c 5
d 5
if I change a = c + b to a = b + c the order is same as spec init order d b c a
so is there something wrong?
my go version is go version go1.12.4 linux/amd64
The text was updated successfully, but these errors were encountered:
terryding77
changed the title
the initialized order
the initialized order d b c a, real result is d c b a
Apr 28, 2019
terryding77
changed the title
the initialized order d b c a, real result is d c b a
doc/spec#Package_initializationthe: initialized order d b c a, real result is d c b a
Apr 28, 2019
ALTree
changed the title
doc/spec#Package_initializationthe: initialized order d b c a, real result is d c b a
doc/spec: Package initialization order: initialized order d b c a, real result is d c b a
Apr 29, 2019
go/doc/go_spec.html
Line 6452 in 049c8db
the code as spec#Package_initializationthe
got
but with the order in spec d-> b -> c -> a, I think the expect result shoud be
if I change
a = c + b
toa = b + c
the order is same as specinit order d b c a
so is there something wrong?
my go version is
go version go1.12.4 linux/amd64
The text was updated successfully, but these errors were encountered: