Besides what others already suggested, you'll find the reason in the
Go memory model specification:
https://golang.org/ref/mem
This part is relevant here:
"If the effects of a goroutine must be observed by another goroutine,
use a synchronization mechanism such as a lock or channel
communication to
Thanks for your reply.
I've tried before and it reported race.
But I don't understand why this code has race, and what's the possible bug?
Here's the output:
$ go run -race main.go
==
WARNING: DATA RACE
Write at 0x00c96000 by goroutine 7:
main.main.func3()
/Users/purewh
Have you tried building with the -race flag?
go build - race
This should help you figure out any data race conditions that may occur.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails fro
Hi,
I wrote some code like below these days, and my colleagues and me are
not sure if the code has any concurrent problem.
Can someone help to figure out if the code has any race problem?
Thanks very much!
Code:
> package main
> import (
"sync"
"sync/atomic"
)
> func main