4 ms·
There 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 i
by ColonelPhantom 6y ago
There 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.