> To see if the the
> race detector would find this potential bug for me, I ran the code with the
> mutex(s) commented out with the  -race flag on and didn't get a warning.

Did you make some concurrent requests? The race detector only tells
you about races that happen, so you need to excercise the concurrent
code paths in some way (possibly in a test or by selectively turning
on -race in a production-like environment).

A couple of general thoughts:

(1) The primary way to know whether a library you're using will call
your code concurrently from multiple goroutines is via documentation.
The net/http documentation, for instance, explains that Serve creates
a goroutine for each connection. Any other library you use should
clearly explain this if it's the case.

(2) net/http and other server packages are a slightly unusual case --
there are many libraries that exist, but most don't call your code
concurrently. (Even packages that invoke provided callbacks are
themselves a minority.) If I use a package that, say, interfaces with
a database or implements a graph algorithm, it would be quite strange
if it used concurrently-invoked callbacks.

-- 
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.

Reply via email to