Skip to content

Instantly share code, notes, and snippets.

@mlowicki
Created October 12, 2016 22:32
Show Gist options
  • Save mlowicki/2866e0bea2bd7cf7eadf46e6e4d26a97 to your computer and use it in GitHub Desktop.
Save mlowicki/2866e0bea2bd7cf7eadf46e6e4d26a97 to your computer and use it in GitHub Desktop.
import "fmt"
func f(ch chan int) {
defer func() {
fmt.Println("Deferred by f")
}()
g()
ch <- 0
}
func g() {
defer func() {
fmt.Println("Deferred by g")
}()
h()
}
func h() {
defer func() {
fmt.Println("Deferred by h")
}()
defer func() {
panic("2nd explosion!")
}()
panic("boom!")
}
func main() {
ch := make(chan int)
go f(ch)
<-ch
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment