# WARNING: DATA RACE: Write by goroutine X, Read by goroutine Y (struct field)

- **ID:** `go/goroutine-racy-struct-field`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Multiple goroutines accessing the same struct field without synchronization.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.0 | active | — | — |
| 1.20 | active | — | — |

## Workarounds

1. **Use mutex to protect struct field** (95% success)
   ```
   type Counter struct {
    mu sync.Mutex
    val int
}
func (c *Counter) Inc() {
    c.mu.Lock()
    c.val++
    c.mu.Unlock()
}
   ```
2. **Use atomic.Value for struct** (85% success)
   ```
   var v atomic.Value
v.Store(MyStruct{Field: 42})
s := v.Load().(MyStruct)
   ```

## Dead Ends

- **Using atomic operations on non-atomic types** — atomic.AddInt64 works only on int64; other types need different approach. (70% fail)
- **Copying struct before access** — Copy doesn't prevent race; original struct still accessed. (80% fail)
