4.12 go panic函数

package main

import "fmt"

func test1(){
	
	fmt.Println("aaaaaaaaaaa")
}
func test2(x int){
	
	fmt.Println("bbbbbbbbb")
	//1显示调用panic,使程序崩溃
	//panic("this is a panic  test !!!")
	
	//2报错显示panic
	var a[10] int
	a[x]=20
}
func test3(){
	
	fmt.Println("ccccccc")
}

func main(){
	test1()
	test2(2)
	test3()
	
	
}
发布了124 篇原创文章 · 获赞 94 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/h4241778/article/details/105347396