3 ms·
Doesn't Go have any syntactic sugar for pass errors out of function? Something like Rust's Carrier/From traits and try! or `?`.
by ordu 9y ago
Doesn't Go have any syntactic sugar for pass errors out of function? Something like Rust's Carrier/From traits and try! or `?`.
- camus2 9y agoNo, go "errors" are just a convention, there is absolutely nothing special about them. Go has panic/defer, which are exceptions, but done badly. They were probably retrofitted in the language when its creators realized they needed exceptions anyway, which makes the whole "error as value" a bit hypocritical. If they truly cared about error as value, then yes, Go would support some form of try! macro.
- stevedonovan 9y agoYes, Rust would be seriously irritating without try! (and its short friend the question mark operator). So I feel the pain of gophers here.
- pjmlp 9y agoNot really, Go community tends to be very vocal against syntactic sugar.