One way to be robust against this particular problem is to carry a pointer to a mutex, rather than embedding a mutex. https://play.golang.org/p/UPY7EBKSYl5
On Sunday, 27 June 2021 at 10:18:52 UTC+1 Brian Candler wrote: > > Shouldn't that result in a panic, even without -race? > > It's not *guaranteed* to panic when you make concurrent accesses to the > same map (hence the point of the race checker). And having two structs > refer to the same map is no different to having two variables refer to the > same map. > > For the OP: one way you could see this problem is if you ever copy > SearchResults by value: > https://play.golang.org/p/LqwXQQzQ4VN > > Note the "go vet" warning here. Have you tried running "go vet" on your > code? > > On Sunday, 27 June 2021 at 05:40:35 UTC+1 kortschak wrote: > >> On Sat, 2021-06-26 at 20:44 -0700, Ian Lance Taylor wrote: >> > Looks like you have multiple SearchResults values that refer to the >> > same map. >> >> >> Shouldn't that result in a panic, even without -race? >> >> Dan >> >> >> -- 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/8f8e35e3-c575-479b-8b90-9f3ed5bb2f92n%40googlegroups.com.