Go goto语句

Go goto语句是一个跳转语句, 用于将控件转移到程序的其他部分。
在goto语句中, 必须有一个标签。我们使用标签来转移程序的控制权。
【Go goto语句】转到语句示例:

package mainimport ("fmt")func main() {var input intLoop:fmt.Print("You are not eligible to vote ")fmt.Print("Enter your age ")fmt.Scanln(& input)if (input < = 17) {goto Loop} else {fmt.Print("You can vote ")}}

输出:
You are not eligible to vote Enter your age 15You are not eligible to vote Enter your age 18You can vote

    推荐阅读