talk-yapc-asia-2015
talk-yapc-asia-2015 copied to clipboard
Data race not fixed using atomic in the talk example
In the code example provided in talk.md
, the data race condition is not fixed by changing visitors++
statement with atomic.AddInt64(&visitors, 1)
.
Also,
w.Write([]byte("<h1 style='color: " + r.FormValue("color") +
"'>Welcome!</h1>You are visitor number " + fmt.Sprint(visitors) + "!"))
must be changed with
w.Write([]byte("<h1 style='color: " + r.FormValue("color") +
"'>Welcome!</h1>You are visitor number " + fmt.Sprint(atomic.LoadInt64(&visitors)) + "!"))