package mainimport ( "fmt" "math/rand")func main() { ch := make(chan int) done := make(chan bool) f := make(chan bool) go func() { for { select { case ch <- rand.Intn(5):{ fmt.Println("随机生成数字") } case <-f: { fmt.Println(111) return } default: } } }() go func() { for i := 0; i < 5; i++ { fmt.Println("Rand Number = ", <-ch) // Print number received on standard output } f <- true done <- true // Send Terminate Signal and return return }() <-done // Exit Main when Terminate Signal received}