Skip to content

Instantly share code, notes, and snippets.

@GhazeyAhmed
Created June 25, 2022 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GhazeyAhmed/ca4589a9db5bd47b53f02d93a6fe0a65 to your computer and use it in GitHub Desktop.
Save GhazeyAhmed/ca4589a9db5bd47b53f02d93a6fe0a65 to your computer and use it in GitHub Desktop.
panic-recover
import "fmt"
func main() {
freakOut()
fmt.Println("Exiting normally")
}
func freakOut() {
defer calmDown()
panic("Oh no")
fmt.Println("I won't run :(")
}
func calmDown() {
recover()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment