5 ms·
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, an
by the_clarence 8y ago
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.
- nvarsj 8y agoIt'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).
- AlexCoventry 8y agoTry gometalinter. https://stackoverflow.com/questions/43898074/is-there-a-way-to-find-not-handled-errors-in-go-code https://stackoverflow.com/questions/43898074/is-there-a-way-...
- thegeekpirate 8y agoSpecifically (if wanted standalone) https://github.com/kisielk/errcheck https://github.com/kisielk/errcheck
- AlexCoventry 8y agoPersonally, I like my linter output in the style of a furious fruit salad, so I go for the kitchen sink.
- networkimprov 8y agoBut there are good ideas on how to do errors better... See Go2 Error Handling feedback: https://github.com/golang/go/wiki/Go2ErrorHandlingFeedback https://github.com/golang/go/wiki/Go2ErrorHandlingFeedback And possible requirements for Go2 errors: https://gist.github.com/networkimprov/961c9caa2631ad3b95413f7d44a2c98a https://gist.github.com/networkimprov/961c9caa2631ad3b95413f...
- deleted 8y ago[deleted]
- tigershark 8y agoExhaustive 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...
- weberc2 8y agoI agree this would be an improvement, but Go’s solution seems to work pretty well.