GoGuide
GoGuide copied to clipboard
关于goto的错误
package main
import "fmt"
func main() {
num := 1
if(num <= 10){
fmt.Println(num)
num++
goto outer // 死循环
}
outer:
fmt.Println("come here")
}
这仅仅是个if判断,也没有无限循环,且goto标记位于语句块之外的结尾处,即使循环也只执行一次,为什么要注释为死循环呢?