I was referring to updating a reference to a string, which can be updated atomically.
This is an advantage that Java offers over Go for concurrent programming. Since everything is reference you don’t face this distinction. Which is why most Go uses channels, which are implemented with locks. > On May 26, 2019, at 1:16 PM, Jan Mercl <0xj...@gmail.com> wrote: > > On Sun, May 26, 2019 at 8:05 PM Sotirios Mantziaris > <smantzia...@gmail.com> wrote: > >> From what i understand you propose to create a new object and switch out the >> old one with the new one using the atomic package of go. > > That cannot work. String is a multi word value. There's nothing in the > atomic package that can update a multi word value. However, a pointer > to anything _can_ be updated atomically. > > You cannot "safely" cheat on the data race. As said before, you must > synchronize (the readers vs writers). There's no other option. > > -- > 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/CAA40n-XTGeeN%3D%3D7R7QMc22KMs_iTWgO4Z%3DWfqoKaFkftenY-7Q%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. -- 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/12A7BCD0-DE93-496D-AF02-6E153CE9C13A%40ix.netcom.com. For more options, visit https://groups.google.com/d/optout.