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

  

 

相关文章:

  • 2022-01-26
  • 2021-08-24
  • 2021-08-05
  • 2021-09-08
猜你喜欢
  • 2022-12-23
  • 2022-03-10
  • 2021-10-28
  • 2021-06-04
  • 2021-11-09
  • 2021-11-20
  • 2022-03-05
相关资源
相似解决方案