Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func f4() {
- defer func() {
- fmt.Println("defer f::anon1()")
- for {
- if p := recover(); p == nil {
- break
- } else {
- fmt.Println("recover panic:",p)
- }
- }
- panic("panic 6")
- }()
- defer func() {
- fmt.Println("defer f::anon2()")
- panic("panic 5")
- }()
- defer func() {
- fmt.Println("defer f::anon3()")
- panic("panic 4")
- }()
- defer func() {
- defer func() {
- panic("start panic : f::anon::anon()")
- panic("panic 2")
- panic("panic 3")
- }()
- defer func() {
- fmt.Println("defer f::anon::anon()")
- }()
- }()
- func() {
- fmt.Println("in f::anon()")
- }()
- }
- func defer_f3() {
- fmt.Println("in defer_f3()")
- recover()
- defer func() {
- fmt.Println("defer defer_f3::anon()")
- }()
- }
- func f3() {
- fmt.Println("f4()")
- f4()
- defer defer_f3()
- }
- func f2() {
- fmt.Println("f3()")
- f3()
- defer func() {
- recover()
- fmt.Println("defer f2()")
- }()
- }
- func f1() {
- fmt.Println("f2()")
- f2()
- defer func() {
- fmt.Println("defer f1()")
- }()
- }
- func main() {
- fmt.Println("f1()")
- f1()
- recover()
- defer func() {
- fmt.Println("defer main::anon()")
- fmt.Println("recover in defer main::anon() :",recover())
- }()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement