golang随机数及pipe
var pipe1 = make(chan int, 1000)
func piTest(){
for{
data := <- pipe1
fmt.Printf("get data:%v\n", data)
}
}
func putData(){
for {
source := rand.NewSource(time.Now().UnixNano())
dataR := rand.New(source).Intn(100)
time.Sleep(time.Second *1 )
pipe1 <- dataR
}
}
func main(){
go piTest()
go putData()
time.Sleep(time.Minute* 1)
}