3 ms·
The author of the blog post is overlooking a major feature here. Go does multiple return types, so you can do things like this: i, err := getValue() however if
by cyberroadie 14y ago
The author of the blog post is overlooking a major feature here. Go does multiple return types, so you can do things like this:
i, err := getValue()
however if you want to ignore a return variable or in this case the returned error you use an underscore like this (same as in haskell):
i, _ := getValue()
This is Go's mechanism for handling (or ignoring errors) which imho is really nice because you don't have to learn anything extra, like throwing/catching error mechanisms
- je42 14y agoThat's not the same as handling an error in a central spot automatically.
- wonderzombie 14y agoHandling errors in one spot doesn't work for all situations, though, right? Especially in an OO environment an object may need context for retrying a request, or some other kind of error decision making. So in practice some exceptions percolate through the object graph, while others are handled in-house, so to speak.
- je42 14y agoIt works for most situations. If you need retry logic - exceptions is the wrong way to go. Errors returned by the standard library are most likely not errors you want to retry by default.
- wonderzombie 14y agoThat depends, though, doesn't it? Just about anything network-related is subject to flakiness, disconnection, and timeouts. That means HTTP, database connections, sockets, etc.