# fatal error: all goroutines are asleep - deadlock! (goroutine leak)

- **ID:** `go/goroutine-leak-channel-buffer`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Goroutines are blocked forever because a channel send has no receiver and the channel is unbuffered.

## Version Compatibility

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

## Workarounds

1. **Ensure every send has a corresponding receive** (95% success)
   ```
   // Before: ch <- 1 (no reader)
// After: 
result := make(chan int)
go func() { result <- doWork() }()
val := <-result
   ```
2. **Use a context with cancellation to clean up goroutines** (90% success)
   ```
   ctx, cancel := context.WithCancel(context.Background())
go func() {
    select {
    case ch <- val:
    case <-ctx.Done():
        return
    }
}()
cancel() // cleanup
   ```

## Dead Ends

- **Increasing buffer size arbitrarily** — Only delays the leak; doesn't match send/receive pattern. (70% fail)
- **Using time.After to timeout** — Goroutine still exists but leaks after timeout; not a clean solution. (60% fail)
