Quoting Effective Go:
The names are not mandatory but they can make code shorter and clearer: they're documentation. If we name the results of nextInt it becomes obvious which returned int is which.
So, named results are means of documentation, e.g. to make clear the purpose of a returned value. They are not there to enable short returns and skipping initialization.
I have the feeling that we abuse this language feature in our code. One indicator is that we return values instead of pointers in a lot of places.
Quoting Effective Go:
So, named results are means of documentation, e.g. to make clear the purpose of a returned value. They are not there to enable short
returns and skipping initialization.I have the feeling that we abuse this language feature in our code. One indicator is that we return values instead of pointers in a lot of places.