To add on; recover itself is a nice code-smell.
If you're using recover, it's probably time to rewrite the func.
I say this because Go forces you (minus just ignoring with _) to error check; so panic's shouldn't happen to start with.
If you're using recover, it's probably time to rewrite the func.
I say this because Go forces you (minus just ignoring with _) to error check; so panic's shouldn't happen to start with.
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.
fmt.Println("foo")
Where did golang force you to error check?How about (taken from here: (https://www.reddit.com/r/programming/comments/ak305l/goodbye...):
r1, err := fn1()
r2, err = fn2()
if err != nil {
return err
}