In Go, what happens when a function calls 'panic()'?

  • The function enters a recovery state and resumes execution after the panic is handled.
  • The function enters a waiting state.
  • The function execution halts and panics, then it starts unwinding the stack, running deferred functions, and returning to the calling function.
  • The program terminates abruptly without executing any further code.
When a function calls 'panic()' in Go, it halts the normal execution flow, triggers a panic, and starts unwinding the stack, executing deferred functions along the way. This typically leads to program termination unless the panic is recovered.
Add your answer
Loading...

Leave a comment

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