mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 07:34:06 +08:00
16 lines
200 B
Go
16 lines
200 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
|
|
}
|
|
}
|