Hacker News new | ask | show | jobs
by ta3411 1304 days ago
Love: - Ecosystem - Clean code - Single executable file

Dislike: - Pointers -- maybe I am still getting the hang of it. But I feel like pointers throw off a lot of beginner programmers. Would love some practical advice here

1 comments

> pointers

Stick with pass-by-value and non-pointer receivers. Use pointers only if you have to.

I worked with one team who deliberately chose pointer receivers for everything. Their reasoning? The compiler can't know if the receiver for the call you are making will be nil at run time, so it doesn't complain.

Yes, they literally chose to subject themselves to runtime panics to silence the compiler.

here’s a good rationale about when to use pointers: https://stackoverflow.com/a/23551970/255463