Panic after defer



examples/panic-after-defer/panic_after_defer.go
package main

import "fmt"

func main() {
    doIt(false)
    fmt.Println()
    doIt(true)
}

func doIt(earlyStop bool) {
    fmt.Println("Start")
    defer fmt.Println("Deferred")
    if earlyStop {
        panic("This is bad")
    }

    fmt.Println("Finish")
}

Start
Finish
Deferred

Start
Deferred
panic: This is bad

goroutine 1 [running]:
main.doIt(0x4db401)
	/home/gabor/work/slides/golang/examples/panic-after-defer/panic_after_defer.go:15 +0x1a5
main.main()
	/home/gabor/work/slides/golang/examples/panic-after-defer/panic_after_defer.go:8 +0x5d
exit status 2