5 ms·
it's not there there's no error handling; it's that there's no exceptions. Instead, you use multiple return values, one of which is an error, and you check the
by zemo 14y ago
it's not there there's no error handling; it's that there's no exceptions. Instead, you use multiple return values, one of which is an error, and you check the return value for an error. It forces you to handle errors at the call site and makes diapers unimplementable.
- chengiz 14y agoHow does it force you to handle errors? Cant you choose to ignore the return value?
- osi 14y agoYou can absolutely ignore it. Or in the case of the Write call, which only returns an error, just never assign it. go's error handling is nice, but since it doesn't force it on you, it leads to errors of omission.
- skybrian 14y agoIf the function returns a useful value and an error then you'll have to assign to error to "_" to ignore it, which is a pretty big hint to the reviewer that it's being suppressed. So in cases where you want to "force" error checking, returning multiple values is probably good enough.
- awj 14y ago> It forces you to handle errors at the call site and makes diapers unimplementable. I don't see how the latter is true. What's the practical difference between wrapping a function call in a try/(no-op)catch and entirely ignoring the error return value?