On Fri, Oct 13, 2017 at 2:05 PM, Alex Buchanan <buchanae.o...@gmail.com>
wrote:

> Basically, I want to spawn a goroutine per object, objects have unique
> IDs, and I want each routine to write its results to a shared map. Nothing
> will be reading from the map while the goroutines are running.
>
> Is this safe?
>
>
Whether this is technically safe *today* in the reference implementation,
it's better to *be* safe.

I suggest using a waitgroup and a channel to collect the results in an
explicitly safe way. Perhaps something like this:
https://play.golang.org/p/1NdQbAW65k

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