• During panic, normal execution stop, defered function in goroutine executed and the program crash with log message
  • Ex. Declare a panic. 
  • A panic causes program to crash. We should handle unexpected situation gracefully by error values.
  • Ex. when panic happen, deferred methods will be called in reversed order until main method
  • Use recover to prevent program crash by a panic
  • Ex. Print stack trace in defer


What to read next

Previous / Next
Previous: Go - Functions - 5 (variadic function, defer) Next: Go - Methods - Pointer Receiver
More like this
Subscribe via RSS: Macro · Tech

Tags:

Updated: