Posts

Showing posts from September, 2022

Go error handling and stack traces voted as the biggest challenge

Image
The results of Go Developer Survey 2022 Q2 came out and showed that error handling and working with stack traces in Go pose the biggest challenge to respondents: "Error handling remains a challenge. Following the release of generics, respondents' top challenge when working with Go shifted to error handling." The answer distribution is as below (click): In this blog post I would like to focus on error handling and try to explain in detail how, in my view, error handling in Go is or should be done. Ready? Let's begin. Error handling in Go explained A function or a method in Go returns a non-nil error if and only if it encounters an error during execution. The caller checks for the returned error value - if it is not nil, it either handles it or returns an error of its own. I hope this blog post makes Go error handling better understood and appreciated.