diff options
Diffstat (limited to 'testdata/recover.go')
-rw-r--r-- | testdata/recover.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/testdata/recover.go b/testdata/recover.go index c7c02c94a..260bf91bd 100644 --- a/testdata/recover.go +++ b/testdata/recover.go @@ -1,5 +1,10 @@ package main +import ( + "runtime" + "time" +) + func main() { println("# simple recover") recoverSimple() @@ -22,6 +27,9 @@ func main() { println("\n# defer panic") deferPanic() + + println("\n# runtime.Goexit") + runtimeGoexit() } func recoverSimple() { @@ -104,6 +112,17 @@ func deferPanic() { println("defer panic") } +func runtimeGoexit() { + go func() { + defer func() { + println("Goexit deferred function, recover is nil:", recover() == nil) + }() + + runtime.Goexit() + }() + time.Sleep(time.Millisecond) +} + func printitf(msg string, itf interface{}) { switch itf := itf.(type) { case string: |