The race in the following test is not detected, because slice operations imitate
accesses only to the beginning of each element, so it detects similar race on x[1].x but
not on x[1].y.
func TestRaceFailingSliceStruct(t *testing.T) {
type X struct {
x, y int
}
c := make(chan bool, 1)
x := make([]X, 10)
go func() {
y := make([]X, 10)
copy(y, x)
c <- true
}()
x[1].y = 42
<-c
}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: