Last active
October 13, 2016 06:08
-
-
Save mlowicki/a4b08c17d5e992d76d6f66f9c6f90d77 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func f() { | |
fmt.Println("Start f") | |
defer func() { | |
fmt.Println("Deferred in f") | |
}() | |
g() | |
fmt.Println("End f") | |
} | |
func g() { | |
fmt.Println("Start g") | |
defer func() { | |
fmt.Println("Deferred in g") | |
}() | |
h() | |
fmt.Println("End g") | |
} | |
func h() { | |
fmt.Println("Start h") | |
defer func() { | |
fmt.Println("1st deferred in h") | |
}() | |
defer func() { | |
fmt.Println("2nd deferred in h") | |
if p := recover(); p != nil { | |
fmt.Printf("Panic found: %v\n", p) | |
} | |
}() | |
defer func() { | |
fmt.Println("3rd deferred in h") | |
}() | |
panic("boom!") | |
} | |
func main() { | |
f() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment