3 ms·
Go panics do not simply abort. "For a real-world example of panic and recover, see the json package from the Go standard library. It encodes an interface with
by ziml77 5y ago
Go panics do not simply abort.
"For a real-world example of panic and recover, see the json package from the Go standard library. It encodes an interface with a set of recursive functions. If an error occurs when traversing the value, panic is called to unwind the stack to the top-level function call, which recovers from the panic and returns an appropriate error value (see the ‘error’ and ‘marshal’ methods of the encodeState type in encode.go)."
From https://go.dev/blog/defer-panic-and-recover https://go.dev/blog/defer-panic-and-recover
- lanstin 5y agoBut philosophically, they should just abort.