http://research.swtch.com/gorace
> ... > The race is fundamentally caused by being able to observe partial updates > to Go's multiword values (slices, interfaces, and strings): the updates are > not atomic. > > The fix is to make the updates atomic. In Go, the easiest way to do that > is to make the representation a single pointer that points at an immutable > structure. When the value needs to be updated, you allocate a new > structure, fill it in completely, and only then change the pointer to point > at it. This makes the assignment atomic: another goroutine reading the > pointer at the same time sees either the new data or the old data, but not > a mix, assuming the compiler is careful to read the pointer just once and > then access both fields using the same pointer value. > ... > -- 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. For more options, visit https://groups.google.com/d/optout.