Go Error Handling

The common complaint about Go is if err != nil being everywhere. As much as it makes the error handling explicit in Go, I quite often see:

foo, err := bar()
if err != nil {
    return nil, err
}

return nil

Errors not being handled and just passed up the stack. I've been refactoring some of our services recently and it reminded of Dave Cheney's post on the subject. It's from a few years ago but still a good explanations of how to handle errors rather than this pattern.

Don't just check errors, handle them gracefully

Don't just check errors, handle them gracefully