GoGuide icon indicating copy to clipboard operation
GoGuide copied to clipboard

关于goto的错误

Open cha0ran opened this issue 3 years ago • 0 comments

package main
import "fmt"
func main() {
	num := 1
	if(num <= 10){
		fmt.Println(num)
		num++
		goto outer // 死循环
	}
outer:
	fmt.Println("come here")
}

这仅仅是个if判断,也没有无限循环,且goto标记位于语句块之外的结尾处,即使循环也只执行一次,为什么要注释为死循环呢?

cha0ran avatar Mar 21 '22 10:03 cha0ran