Hacker News new | ask | show | jobs
by rochak 1096 days ago
Pointer vs value receivers and named returns have so many gotchas that it is not even funny. Lack of magic my ass.
2 comments

The way you avoid these are twofold:

1) Use the pointer receiver unless you have a really good reason to do otherwise.

2) Never, ever use named returns. Code can (and should) always be written to not use them.

Can you elaborate point 2, please?I am wondering how is that related to the issue of pointer and value semantics.
Can you name any? I have never seen a “gotcha” because it’s just explicit… it’s not like you are surprised by a pointer.