Created
November 13, 2019 13:07
-
-
Save shibukawa/52fbd7791ffde23dea4fff7178a95373 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% go run -race test.go | |
================== | |
WARNING: DATA RACE | |
Write at 0x00c00009c000 by goroutine 7: | |
main.main.func2() | |
/Users/shibukawa/test.go:15 +0x7e | |
Previous write at 0x00c00009c000 by goroutine 6: | |
main.main.func1() | |
/Users/shibukawa/test.go:12 +0x7e | |
Goroutine 7 (running) created at: | |
main.main() | |
/Users/shibukawa/test.go:14 +0xfa | |
Goroutine 6 (finished) created at: | |
main.main() | |
/Users/shibukawa/test.go:11 +0xce | |
================== | |
Found 1 data race(s) | |
exit status 66 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"time" | |
) | |
func main() { | |
var f bool | |
a := make(map[int]bool) | |
a[1] = true | |
go func() { | |
f = a[1] | |
}() | |
go func() { | |
f = a[1] | |
}() | |
time.Sleep(time.Second) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment