The recover function must be called within a _____ function to catch a panic.

  • defer
  • panic
  • recover
  • func
To catch a panic in Go, the recover function must be called within a defer function. The defer statement is used to schedule a function call to be executed just before the function that contains the defer statement returns. This is typically where you would use recover to catch and handle panics to prevent the program from crashing.
Add your answer
Loading...

Leave a comment

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