Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
Created October 26, 2017 06:07
Show Gist options
  • Save lamarmarshall/f13bccdc7b5552df512e9b4e8b4f675e to your computer and use it in GitHub Desktop.
Save lamarmarshall/f13bccdc7b5552df512e9b4e8b4f675e to your computer and use it in GitHub Desktop.
go paniic recover
package main
import (
"fmt"
)
func main() {
fmt.Println("program started to run")
testpanic()
fmt.Println("program ended")
}
func testpanic() {
defer func() {
if err := recover(); err != nil {
fmt.Println(err)
fmt.Println("we recovered from the error")
}
}()
// throw exception
panic("this shit blew up !!!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment