Go Channels
Go Channels
// 单向channel
func main() {
naturals := make(chan int)
squares := make(chan int)
done := make(chan struct{})
go Counter(naturals)
go Squarer(naturals, squares)
go Printer(squares, done)
<-done
}
func Counter(naturals chan<- int) {
转载
2020-07-05 23:14:51 ·
66 阅读 ·
0 评论