Rob*_*bin -2 dictionary go race-condition
-race
--- FAIL: TestRaceCondition (0.00s)
testing.go:853: race detected during execution of test
func TestRaceCondition(t *testing.T) {
var map sync.Map
for i := 0; i < 10; i++ {
go func() {
map.Store(strconv.Itoa(i), nil)
}()
}
}
我不明白,因为根据文档,
Map [...] 对于多个 goroutine 并发使用是安全的,无需额外的锁定或协调。