Re:Nine years of Go
by the_clarence on Saturday November 10, 2018 @03:25PM
(#18423303)
There is no better way to do errors imo, unless you're going the erlang way of "let it fail". Errors can be passed to the caller the same way exceptions are, and it becomes an endless pursuit of where the error is actually being handled (if at all). I agree that some syntax sugar helps, see Rust, but it doesn't completely fixes the problem.
[ Parent
| on HN ]
It's baffling though that the compiler doesn't at least warn when you forget to check the err. So many edge cases with that (especially due to `:=` vs `=` if reassigning a prior err).
Re:Nine years of Go
by AlexCoventry on Saturday November 10, 2018 @08:33PM
(#18424541)
Try gometalinter. https://stackoverflow.com/questions/43898074/is-there-a-way-...
Re:Nine years of Go
by thegeekpirate on Sunday November 11, 2018 @12:26AM
(#18425142)
Specifically (if wanted standalone) https://github.com/kisielk/errcheck
Re:Nine years of Go
by AlexCoventry on Sunday November 11, 2018 @12:46AM
(#18425172)
Personally, I like my linter output in the style of a furious fruit salad, so I go for the kitchen sink.
Re:Nine years of Go
by networkimprov on Saturday November 10, 2018 @05:39PM
(#18423908)
But there are good ideas on how to do errors better...
See Go2 Error Handling feedback:
https://github.com/golang/go/wiki/Go2ErrorHandlingFeedback
And possible requirements for Go2 errors:
https://gist.github.com/networkimprov/961c9caa2631ad3b95413f...
Re:Nine years of Go
by tigershark on Saturday November 10, 2018 @06:23PM
(#18424064)
Exhaustive pattern matching combined with ADT seems way better to me compared to the go error handling where it is pretty much guaranteed that you will shoot your own foot forgetting to handle some errors...