package main
import "fmt"
func printIsOdd(n int) {
if n%2 == 1 {
goto isOdd
}
fmt.Printf("%d is even\n", n)
return
isOdd:
fmt.Printf("%d is odd\n", n)
}
func main() {
printIsOdd(5)
printIsOdd(18)
}
goto end
a := 3 // var a int 也是声明语句,也不可被越过
fmt.Printf("a: %d\n", a)
end:
// build时会报错:
// goto ... jumps over declaration of a at ...