The concurrent write of map may be detected at runtime. However, the delete of map (write operation maybe?) was never detected. The race
option does not catch the race condition too. Please take a look at the code below. I’m guessing the lack of race condition in the delete function call is because of the runtime overhead. What kind of reason for this lack of detection in the race condition of the delete function call? Thank you
package main
import (
"fmt"
"time"
)
func main() {
m := make(map[string]string)
m["hello"] = "world"
for i := 0; i < 10000; i++ {
go func() {
delete(m, "hello")
// m["hello"] = "world"
}()
}
time.Sleep(time.Second)
fmt.Println(m)
}