You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"fmt"
)
type Fruit struct {
Name string
}
func main() {
Race()
}
func Race() (newFruit Fruit) {
go func() {
newFruit = Fruit{Name: "Pear"}
}()
fmt.Printf("race3:exp:Pear,act:%v", newFruit.Name)
return
}
//go run --race main.go
out put
PS D:\source\gopath\src\race\gofunc> go run --race main.go
race3:exp:Pear,act:==================
WARNING: DATA RACE
Write at 0x00c00003e1d0 by goroutine 6:
main.Race.func1()
D:/source/gopath/src/race/gofunc/main.go:17 +0x3f
Previous read at 0x00c00003e1d0 by main goroutine:
runtime.convT2Estring()
C:/GO/src/runtime/iface.go:332 +0x0
main.Race()
D:/source/gopath/src/race/gofunc/main.go:19 +0x8e
main.main()
D:/source/gopath/src/race/gofunc/main.go:13 +0x36
Goroutine 6 (running) created at:
main.Race()
D:/source/gopath/src/race/gofunc/main.go:16 +0x6c
main.main()
D:/source/gopath/src/race/gofunc/main.go:13 +0x36
==================
Found 1 data race(s)
exit status 66
The text was updated successfully, but these errors were encountered:
xiaoxinmiao
added a commit
to xiaoxinmiao/echosample
that referenced
this issue
Nov 25, 2018
This code will cause data competition
//go run --race main.go
out put
The text was updated successfully, but these errors were encountered: