go语言基础之goto的用法


1、goto的用法

示例:

package main //必须有一个main包

import "fmt"

func main() {

	//break //break is not in a loop, switch, or select
	//continue//continue is not in a loop

	//goto可以用在任何地方,但是不能夸函数使用
	fmt.Println("11111111111111")

    //go to的作用是跳转,中间的语句不执行,无条件跳转
	goto End //goto是关键字, End是用户起的名字, 他叫标签

	fmt.Println("222222222222222")

End:
	fmt.Println("3333333333333")

}

#执行结果:

11111111111111
3333333333333

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM