> [..] when the method modifies the sruct's members (or just have a 
sync.Mutex member)

>From my experience, these are the major points for defaulting to use the 
pointer receiver "when in doubt". The difference between "func (t T) Foo" 
and "func (t *T) Foo", is often too subtle to spot a bug in a code change 
of a real production project. This is for sure, not the ultimate solution 
for human-errors. But it's pragmatic.

On Tuesday, November 14, 2023 at 6:37:27 AM UTC+1 Tamás Gulácsi wrote:

> I've always try to start with a value receiver,
> change to pointer receiver (EVERYWHERE - do not mix pointer and value 
> receivers!),
> when the method modifies the sruct's members (or just have a sync.Mutex 
> member),
> or used as interface (i.e. error  - for comparison to nil)
>
> Oliver Lowe a következőt írta (2023. november 14., kedd, 0:23:44 UTC+1):
>
>> > I'd be curious to hear thoughts on this topic. 
>>
>> There was a fun talk at GopherConAU just a few days ago: "What's 
>> The Point? A Guide To Using Pointers Without Panicking" (talk 
>> description at https://gophercon.com.au/) When the recordings are 
>> all finalised I can reply to this thread with a link. 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/38dea6ca-5dc8-4e78-b50d-ca10f00bbaabn%40googlegroups.com.

Reply via email to