Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple initializers in a Go if statement

Tags:

Just discovered Go, and am very curious so far. I know I'm just being lazy, but I want to know if it is possible to initialize multiple variables in an if statement. I know that the following is possible:

if x := 5; x == 5 {
    fmt.Printf("Whee!\n")
}

I've tried the following:

if x := 5, y := 38; x == 5 {
    fmt.Printf("Whee! %d\n", y)
}

if x := 5 && y := 38; x == 5 {
    fmt.Printf("Whee! %d\n", y)
}

But neither worked. I looked over the documentation on the Go website, so is there anything I am missing or is this simply not possible?