mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 06:23:59 +08:00
17 lines
217 B
Go
17 lines
217 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
ch1 := make(chan int)
|
|
go pump(ch1) // pump hangs
|
|
fmt.Println(<-ch1) // prints only 0
|
|
}
|
|
|
|
func pump(ch chan int) {
|
|
for i := 0; ; i++ {
|
|
ch <- i
|
|
}
|
|
}
|
|
|