3 ms·
I did not like it at first but now I kind of got used to it. It makes errors very explicit. Other language alternative is wrapping in try catch block. Wrapping
by akmittal 6y ago
I did not like it at first but now I kind of got used to it. It makes errors very explicit. Other language alternative is wrapping in try catch block.
Wrapping everything statement which can produce error is more tedious.
- ColonelPhantom 6y agoThere are other alternatives as well. For example, Rust uses a Result tagged union. You can also shorthand it using the ? operator, which does the same as the if err != nil { return nil, err; } but without all the boilerplate. There are some inconveniences, like needing to specify the error type by hand, but overall the amount of code is far smaller, it is a lot harder to mess up return types, yet it remains equally explicit in forcing you to handle every error, which is something that Go doesn't do.