# fatal error: all goroutines are asleep - deadlock! (main exits without waiting)

- **ID:** `go/goroutine-not-joining`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Main function exits while other goroutines are still running, but they are blocked on channels or other operations, causing deadlock detection.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   Use sync.WaitGroup to wait for all goroutines to finish before returning from main.
   ```
2. **** (90% success)
   ```
   Use a done channel and close it when all work is done; main blocks on <-done.
   ```

## Dead Ends

- **** — Sleep is nondeterministic; goroutines may finish later or never, and it's inefficient. (70% fail)
- **** — Program exits prematurely, possibly leaving resources unclean or missing results. (90% fail)
