Skip to content

Instantly share code, notes, and snippets.

@utahta
Created December 2, 2017 21:35
Show Gist options
  • Save utahta/68702b6a84b87d26bdc7580402db799c to your computer and use it in GitHub Desktop.
Save utahta/68702b6a84b87d26bdc7580402db799c to your computer and use it in GitHub Desktop.
panic defer behavior in go
package main
import (
"fmt"
"time"
)
func doPanic() {
defer fmt.Println("--- print ---")
panic("ʕ◔ϖ◔ʔ")
}
func doPanicGo() {
defer fmt.Println("--- can not print ---")
go doPanic()
time.Sleep(10 * time.Second)
}
func main() {
doPanicGo()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment