I wrote a simple function and hope it has a race alarm under the `-race` 
flag:

package main

import (
        "fmt"
        "time"
)

func main() {
        a := 1
        go func() {
                fmt.Println(a) // If I remove this instruction, the 
detector will report a data race
                a = 3
        }()
        fmt.Println(a)
        time.Sleep(time.Second)
}

I am confused, why there is no data race in the above program. I'm using 
go1.17.2 linux/amd64

-- 
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/3833aa84-9614-4815-ba1b-700b2de51df8n%40googlegroups.com.

Reply via email to