3 ms·
Here are my rules of thumb: 1. Only panic in the top level main() function. Bubble up all errors from sub functions and libraries to the top level function and
by __turbobrew__ 2y ago
Here are my rules of thumb:
1. Only panic in the top level main() function. Bubble up all errors from sub functions and libraries to the top level function and then decide what to do from there.
2. If you want to offer a library function which can panic on errors, create two versions of the function: one which returns an error, and one which panics on an error and has a name which starts with ’Must’. For example Load() returns an error and MustLoad() doesn’t return an error and instead panics on error.