package main

import "fmt"

func fn_test_panic() (a int) {
	a = 2
	panic("This is panic")
	return a
}

func fn1() (a int) {
	a = 3
	defer func(){
		if p := recover(); p != nil {
			fmt.Println("recover")
		}
	}()
	fmt.Println("befor call panic")
	b := fn_test_panic()
	fmt.Println("after call panic")
	a = b
	return a
}
func main() {
	fmt.Println("return code:", fn1())
}

相关文章:

  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
猜你喜欢
  • 2022-01-16
  • 2021-10-11
  • 2022-02-20
  • 2021-10-09
  • 2021-08-03
  • 2021-07-31
相关资源
相似解决方案