On 26/06/21, Ian Lance Taylor (i...@golang.org) wrote:
> On Sat, Jun 26, 2021 at 3:27 PM Rory Campbell-Lange <rory...@gmail.com> wrote:
> >
> > I'm trying to work out why I have a data race problem (on go 1.15 and 1.16).
> >
> > *SearchResults.Set is called from several goroutines. I am trying to avoid 
> > concurrent access to its two maps using a mutex, but this isn't working.
> 
> Looks like you have multiple SearchResults values that refer to the same map.

Thanks for the insightful comment -- I was passing SearchResults to the 
goroutine by value instead of by reference.

By the way, as a golang newbie, it isn't clear to me when it is advisable to
use a channel for locking as opposed to a mutex. Do people tend to use the 
former?

Thanks again,
Rory

-- 
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/20210627093149.GA5588%40campbell-lange.net.

Reply via email to