4 ms·
One technical challenge to using panic to represent normal exceptions is that most go code is then not exception safe. This was a design choice for the ecosyste
by unbrice 2y ago
One technical challenge to using panic to represent normal exceptions is that most go code is then not exception safe. This was a design choice for the ecosystem if not the language itself (see eg: Effective go about panic not crossing package boundaries, or Google's style guide).
Within a package it can work, but then you'll find language support lacking. For example defer is scoped to a function so you need to write pretty unusual code to make the equivalent of a try block.