DEV Community

Discussion on: Introduction to Go for PHP Developers

Collapse
 
ameliagapin profile image
Amelia Gapin

At first, I wasn't a fan of this. It made the code feel cumbersome. After a bit, I not only got used to it, but came to embrace it. It makes error handling much more a natural part of the way you code. You can avoid the scoping of a try/catch block because you don't have to put your code into another block.

The compiler will ensure that you've recognized the error is part of the return (when using a multi-return function) so you don't have to worry about being unaware of it. If you do anything with it and what you do is up to you. You could choose to ignore it by assigning it to _ instead of a variable.