Created
December 6, 2019 14:24
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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