go
runtime_error
ai_generated
true
fatal error: all goroutines are asleep - deadlock! (goroutine 1 [chan receive])
ID: go/goroutine-leak-no-sender
80%Fix Rate
86%Confidence
0Evidence
2024-04-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.20 | active | — | — | — |
| 1.21 | active | — | — | — |
Root Cause
A goroutine is blocked receiving from a channel that never receives data, with no active sender.
generic中文
一个 goroutine 在从一个永远不会接收数据的通道接收时阻塞,没有活动的发送者。
Workarounds
-
95% success
ch := make(chan int); go func() { ch <- 42 }(); val := <-ch -
85% success
select { case val := <-ch: case <-time.After(time.Second): }
Dead Ends
Common approaches that don't work:
-
70% fail
Receive from closed channel returns zero value immediately, not blocking, but may not be desired.
-
90% fail
Sleep doesn't create a sender; still blocks forever.