Skip to content

Instantly share code, notes, and snippets.

@rhcarvalho
Created December 6, 2019 14:24
Show Gist options
  • Save rhcarvalho/c089a2d25d7e5b2ed6a4581b89f879b7 to your computer and use it in GitHub Desktop.
Save rhcarvalho/c089a2d25d7e5b2ed6a4581b89f879b7 to your computer and use it in GitHub Desktop.
Go cannot capture panics in arbitrary goroutines - https://play.golang.org/p/_YUfKreCkeY
package main
import (
"fmt"
)
func main() {
done := make(chan int)
defer func() {
<-done
}()
defer func() {
if err := recover(); err != nil {
fmt.Println("Recovered from:", err)
}
}()
fmt.Println("Hello, playground")
go func() {
defer close(done)
panic("err goroutine")
}()
panic("err main")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment