I've never used Go but having used other languages with exception-based error handling, I get why Go decided to go in a different direction... but reading this over...
Okay, so surely some syntactic sugar could make it more pleasant than the
if (err != nil) {
return nil, err
}
repeated boilerplate. Like, if that return is a tagged union you could do some kind of pattern matching?
... oh, Go doesn't have sum-types. Or pattern matching.
Could you at least do some kind of generic error handler so I can call
y := Handle(MyFuncThatCanReturnError(x))
?
... Okay, GoLang does not have tuples. Multiple returns must be handled separately.
Okay could I write some kind of higher-order function that handles it in a generic way? Like
y := InvokeWithErrorHandler(MyFuncThatCanReturnError, x)
?
No? That's not an option either?
... why do you all do this to yourselves?
Okay, so surely some syntactic sugar could make it more pleasant than the
repeated boilerplate. Like, if that return is a tagged union you could do some kind of pattern matching?... oh, Go doesn't have sum-types. Or pattern matching.
Could you at least do some kind of generic error handler so I can call
?... Okay, GoLang does not have tuples. Multiple returns must be handled separately.
Okay could I write some kind of higher-order function that handles it in a generic way? Like
?No? That's not an option either?
... why do you all do this to yourselves?