On Wed, Oct 17, 2018 at 8:37 AM <[email protected]> wrote: Hi,
I am having issues with some concurrency and race conditions. > I believe this is not doing what I think it does. IE I am thinking this would allow locking of any variable in the struct however it does not seem to be applying to buffer of type bytes.Buffer. What am I missing here? sync.Mutex locks only itself, nothing else. To access fields of a struct exclusively/one goroutine at a time, one has to follow a discipline: lock the mutex, access the field, unlock the mutex. Any other goroutine that's not following this "protocol" is able to access the struct fields concurrently regardless of the state of the mutex. -- -j -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
