Files
the-way-to-go_ZH_CN/eBook/exercises/chapter_14/random_bitgen.go

24 lines
207 B
Go
Executable File

package main
import (
"fmt"
)
func main() {
c := make(chan int)
// consumer:
go func() {
for {
fmt.Print(<-c, " ")
}
}()
// producer:
for {
select {
case c <- 0:
case c <- 1:
}
}
}