4 ms·
Your code is allowed to panic if there is a bug. For instance, the caller passed in a nil pointer where there needed to be actual data. Errors are for when the
by skj 8y ago
Your code is allowed to panic if there is a bug. For instance, the caller passed in a nil pointer where there needed to be actual data.
Errors are for when the input (specifically the I/O) is wrong, a precondition isn't met, or some other error that doesn't mean there is something fundamentally wrong with your code.
If to make the problem go away you need to fix the code, panic is OK.