> Disadvantage 2 – Error Handling I'm by no means a Go expert, but it felt like Go forced consistent error handling. > Another issue is that it’s easy to forget to handle an error by accident Does anyone have specific examples of error scenarios that skip through the cracks? > While this approach works, it’s easy to lose scope of what went wrong to ensure you can provide a meaningful error to your users. The errors p…
Error variable shadowing is a big one that occurs in go codebases. Along with the re-use of for loop variables, it is the most common Go footgun. The go language guys could fix both of these easily - force the caller to check error or explicitly drop it (_) optionally if non-null. That would almost completely eliminate the problem. I really like Go - I can pick up pretty much any Go code, from any open source project…
I don't want that because I don't want to litter my code with `_ = fmt.Printf()`
`Printf()` is a very common function. It returns an error. I don't care about an error from `Printf` and I don't want to make my code more ugly to avoid bugs I'm not writing in the first place.
I've been writing Go code since before v1. I really can't recall a case where I wrote a bug because I forgot to handle an error.
I get how you can forget something you do once a month.
I don't get how you can forget to handle an error in Go when that's something you do every couple of lines of code written.