In Go, you have something like:
func main() {
defer func() {
if r := recover(); r != nil {
/*run some clean up code here...*/
fmt.Println("Recovered")
}
}()
/*Some code right here like a web server that runs until panic or ctrl-c'd out */
}
If I ctrl-C in Linux, will it run the defer? Or does it immediately exit? If it immediately exits, is there a way around that? A way to run code, no matter what, on exit of the app?