0
点赞
收藏
分享

微信扫一扫

Golang协程-通道遍历


range-over-channels.go

package main

import "fmt"

func main() {
	queue := make(chan string, 2)
	queue <- "one"
	queue <- "two"
	close(queue)
	for elem := range queue {
		fmt.Println(elem)
	}
}

Golang协程-通道遍历_后端

 

举报

相关推荐

0 条评论