# warning: goroutine sleeping in loop (goroutine 9)

- **ID:** `go/goroutine-sleep-in-loop`
- **Domain:** go
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A goroutine calls time.Sleep in a tight loop, consuming resources and potentially blocking.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   ticker := time.NewTicker(time.Second)
defer ticker.Stop()
for range ticker.C {
    // do work
}
   ```
2. **** (85% success)
   ```
   select {
case <-time.After(time.Second):
    // do work
case <-ctx.Done():
    return
}
   ```

## Dead Ends

- **** — Still busy-waits; doesn't solve the underlying issue. (80% fail)
- **** — Gosched doesn't block; it just yields, but loop continues. (70% fail)
- **** — Wastes CPU and may cause performance issues. (90% fail)
