Intermediate Go (Golang)
Q100 / 100

What is the difference between panic and log.Fatal in Go?

Correct! Well done.

Incorrect.

The correct answer is B) panic unwinds the stack and can be recovered; log.Fatal prints a message and calls os.Exit(1), which cannot be recovered and skips deferred functions

B

Correct Answer

panic unwinds the stack and can be recovered; log.Fatal prints a message and calls os.Exit(1), which cannot be recovered and skips deferred functions

Explanation

Use log.Fatal in main() for unrecoverable startup errors. panic is for invariant violations. os.Exit skips deferred cleanup — prefer panic in libraries.

Progress
100/100