Lastly, the only reason that changing to a pointer receiver “solves” the race is because the field in the object isn’t accessed - something the compiler could detect in the other version as well.
> On Nov 13, 2023, at 10:50 PM, Robert Engels <reng...@ix.netcom.com> wrote: > > Similarly, even in a single threaded Java program objects are copied/moved > behind the scenes - these don’t generate race conditions as the runtime > ensures there isn’t one. > >> On Nov 13, 2023, at 10:47 PM, Robert Engels <reng...@ix.netcom.com> wrote: >> >> To me this is a limitation of the compiler. If a passed argument is unused >> it doesn’t even need to be created. Similarly if only a few fields are used >> in a called function a sparse data object can be sent. It only becomes a >> race if the data being copied is actually used - then the race is also >> obvious. >> >>>>> On Nov 13, 2023, at 10:27 PM, 'Dan Kortschak' via golang-nuts >>>>> <golang-nuts@googlegroups.com> wrote: >>>>> >>>>> On Mon, 2023-11-13 at 19:38 -0800, Mike Schinkel wrote: >>>>> I have been wondering for a while why the advice against mixing >>>>> pointer and value receivers, which GoLang so often flags me for >>>>> doing. >>> >>> https://dave.cheney.net/2015/11/18/wednesday-pop-quiz-spot-the-race >>> >>> -- >>> 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/3cc8112142c151ffea7fe640a2e7150fafcf202d.camel%40kortschak.io. -- 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/32B1BD5C-56E8-4518-A470-3A0A9305B25A%40ix.netcom.com.