Created
December 2, 2017 21:35
-
-
Save utahta/68702b6a84b87d26bdc7580402db799c to your computer and use it in GitHub Desktop.
panic defer behavior in go
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" | |
"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