3 ms·
I wish they would improve the syntax for error handling with multiple return values. When your function returns something like (string, error) you need to write
by jasonthorsness 2y ago
I wish they would improve the syntax for error handling with multiple return values. When your function returns something like (string, error) you need to write:
return "", err
each time. Then if you introduce another return value, you need to edit a ton of lines to also return a value for that one, typically just to return the default of each along with the error. Not only is that annoying, but it's prone to carelessly returning something non-default along with the error due to copy/pasting. But complaints aside, I agree with the article that Go's error handling is pretty awesome.