Is it possible to resume execution after a 'panic()' in Go?

  • No, once a panic occurs, the program terminates
  • No, panics cannot be recovered in Go
  • Yes, by calling 'recover()' within a deferred function
  • Yes, by using a try-catch block
Yes, it's possible to resume execution after a panic in Go by using the 'recover()' function within a deferred function. When a panic occurs, the control transfers to deferred functions, and by calling 'recover()' in one of these deferred functions, the program can continue execution.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *