package main
import (
"fmt"
)
func ready(c chan int, quit chan bool){
for {
j := <- c
fmt.Println("ready ", j)
}
<- quit
}
func main() {
c := make(chan int)
quit := make(chan bool)
go ready(c, quit)
for i := 0; i < 2; i++ {
c <- i
fmt.Println("main ", i)
}
quit <- false
}
错误是这样的:
fatal error: all goroutines are asleep - deadlock!
有疑问加站长微信联系(非本文作者)