一个很简单小程序:
package main
import (
"fmt"
)
func main() {
var rand_number int64
ch := make(chan int64, 3)
for i := 0; i < 3; i++ {
select {
case ch <- 0:
case ch <- 1:
case ch <- 2:
case ch <- 3:
case ch <- 4:
case ch <- 5:
case ch <- 6:
case ch <- 7:
case ch <- 8:
case ch <- 9:
}
rand_number = rand_number*10 + <-ch
}
fmt.Println(rand_number)
}