Похожие чаты

Can someone pls explain this? Here is the source code for

sync.waitgroup:
https://golang.org/src/sync/waitgroup.go?s=2022:2057#L43

Why does the (T *WaitGroup) receiver not throw an error when I call it on a non-pointer type (T WaitGroup) ?

5 ответов

25 просмотров

As a rule of thumb, I personally use a pointer reciver in case I want to mutate something inside the struct. And non pointer in case I don't want to

Justin-K Автор вопроса
A​kshit
As a rule of thumb, I personally use a pointer rec...

Thanks, I have been doing this too. I got confused earlier with ‘pointer/non pointer’ consideration with interfaces vs their general reference use. I have replicated a few examples and now understand this nuance much better.

https://play.golang.org/p/4IQzUJyw0_o a pointer-reciver just takes the pointer of the variable you're calling it on+

Justin-K Автор вопроса
Roman Sharkov
https://play.golang.org/p/4IQzUJyw0_o a pointer-r...

Thank you, I understand that. I'm going to send a playground link in a bit of what actually got me confused.

Justin-K Автор вопроса
Roman Sharkov
https://play.golang.org/p/4IQzUJyw0_o a pointer-r...

https://play.golang.org/p/YdinlQBN_0E For a moment, I mixed up subtle differences between interface and concrete types, in the context of a method receiver. (Refer to line 31 and 28. ) I mistook that for a non-pointer type, I could not call its pointer receiver (as with type interface). I know better now but please do correct me if you notice gap in my understanding. Thanks!

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта