A panic is an exception in Go
Panics are similar to C++ and Java exceptions,
but are only intended for run-time errors,
such as following a nil pointer or attempting to index an array out of bounds.
To signify events such as end-of-file,
Go programs use the built-in
A panic stops the normal execution of a goroutine.
When a program panics, it immediately starts to unwind the call stack.
This continues until the program crashes and prints a stack trace,
or until the built-in
recover function is called.
See Recover from a panic for details.
A panic is caused either by a runtime error,
or an explicit call to the built-in
Error handling explained
Share this page: