Re: [go-nuts] Unexpected behavior with panic/defer/recover

2017-03-28 Thread Steven Hartland
You second example isn't calling recover inside the defer. See: https://golang.org/pkg/builtin/#recover On 28/03/2017 23:00, Stefan Engstrom wrote: Playing with recovery from a panic - this code does what i expect: (https://play.golang.org/p/p5KvOYc1sx) | packagemain import"fmt" func main(){

[go-nuts] Unexpected behavior with panic/defer/recover

2017-03-28 Thread Stefan Engstrom
Playing with recovery from a panic - this code does what i expect: ( https://play.golang.org/p/p5KvOYc1sx) package main import "fmt" func main() { defer func() { fmt.Println("main:",recover()) }() a() } func a() { panic("yikes") } Results in: main: yikes A simpler version with