Re: [go-nuts] Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-16 Thread Victor Giordano
You may forgive me. El jue, 16 nov 2023 a las 11:57, Mike Schinkel () escribió: > On Thursday, November 16, 2023 at 9:16:22 AM UTC-5 Victor Giordano wrote: > > Lads, I guess this entry and the > subsequent entries are very important regarding the discussion. >

Re: [go-nuts] Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-16 Thread Mike Schinkel
On Thursday, November 16, 2023 at 9:16:22 AM UTC-5 Victor Giordano wrote: Lads, I guess this entry and the subsequent entries are very important regarding the discussion. *Also we shall recall that T and *T are different types. * *Golang performs some implicit

Re: [go-nuts] Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-16 Thread Victor Giordano
Regarding the Original question: I guess the advice of using a pointer receiver can be OK as long you know what you are coding. quoting "https://go.dev/tour/methods/8; > There are two reasons to use a pointer receiver. > The first is so that the method can modify the value that its receiver

Re: [go-nuts] Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-15 Thread Mike Schinkel
> On Nov 15, 2023, at 7:08 AM, 'Brian Candler' via golang-nuts > wrote: > > On Tuesday, 14 November 2023 at 03:38:04 UTC Mike Schinkel wrote: > 1. A value variable and multiple value receivers <--- compiles > 2. A pointer variable and multiple value receivers <--- compiles > 3. A pointer

Re: [go-nuts] Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-13 Thread Vladimir Varankin
> [..] 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

Re: [go-nuts] Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-13 Thread Tamás Gulácsi
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

Re: [go-nuts] Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-13 Thread Oliver Lowe
> 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.

[go-nuts] Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-13 Thread 'Brad Johnson' via golang-nuts
Google's style guide is a popular reference for Go programmers. In it, they list off a number of scenarios where one would use a value receiver vs a pointer receiver. But, ultimately, they end the list with "when in doubt, use a pointer receiver". In my experience, I've noticed the majority of