# fatal error: all goroutines are asleep - deadlock! (sync.Once.Do recursion)

- **ID:** `go/sync-once-reentrant`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A sync.Once.Do function calls Do again on the same Once (directly or indirectly), causing self-deadlock because Once holds an internal mutex while running f.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   var once sync.Once
once.Do(func() {
    // do not reference `once` here
    initConfig()
})
   ```
2. **** (88% success)
   ```
   var onceA, onceB sync.Once
onceA.Do(initA)
onceB.Do(initB)
   ```

## Dead Ends

- **** — The deadlock is internal to Once; no timeout can break the held mutex. (90% fail)
- **** — Reintroduces the data race Once was meant to prevent. (70% fail)
