Files
the-way-to-go_ZH_CN/eBook/exercises/chapter_14/goroutine_panic.go
2015-03-03 12:25:25 -05:00

23 lines
272 B
Go
Executable File

package main
import (
"fmt"
)
func tel(ch chan int) {
for i := 0; i < 15; i++ {
ch <- i
}
}
func main() {
var ok = true
ch := make(chan int)
go tel(ch)
for ok {
i := <-ch
fmt.Printf("ok is %t and the counter is at %d\n", ok, i)
}
}