update book code

This commit is contained in:
Unknwon
2015-03-03 12:25:25 -05:00
parent b8c82ba4e5
commit eab1d98ba8
465 changed files with 15392 additions and 1572 deletions

View File

@@ -0,0 +1,31 @@
// Q20b_goroutine.go
package main
import (
"fmt"
"os"
)
func tel(ch chan int, quit chan bool) {
for i:=0; i < 15; i++ {
ch <- i
}
quit <- true
}
func main() {
var ok = true
ch := make(chan int)
quit := make(chan bool)
go tel(ch, quit)
for ok {
select {
case i:= <-ch:
fmt.Printf("The counter is at %d\n", i)
case <-quit:
os.Exit(0)
}
}
}