channel directions
来源:互联网 发布:游戏画质优化 编辑:程序博客网 时间:2024/04/26 06:59
packagemain
//channel directions
//通道作为函数参数,你需要指明通道是作为发送还是接受。
//这种指明提高了程序类型的安全
import "fmt"
func ping(pings chan<- string, msg string) {
pings <- msg
}
// 通道作为参数
func pong(pings <-chan string, pongs chan<- string) {
msg := <-pings
pongs <- msg
}
func main() {
pings := make(chan string, 1)
pongs := make(chan string, 1)
ping(pings, "passed message")
pong(pings, pongs)
fmt.Println(<-pongs)
}
0 0
- channel directions
- Channel
- channel
- channel
- Channel
- channel
- Channel
- Channel
- android google directions
- UVA610 Street Directions
- POJ 1515 Street Directions
- UVA610 - Street Directions(Tarjan)
- poj1515 Street Directions
- igllib 203 Curvature directions
- codeforces838B-Diverging Directions
- Directions Reduction -- 5 kyu
- UVA 610 Street Directions
- Bing Maps Gets Transit Directions
- FIFO 队列的链表和数组实现
- sample——log4j
- swift 构建桥接文件
- storm笔记:storm集群
- action之访问Servlet API
- channel directions
- iOS之轻松上手block(上)
- Dom7(动态创建标签,获取页面元素)
- 六款大数据采集平台的架构分析
- Hadoop集群搭建工作日志
- js判断安卓或者ios
- scrollView中放ViewPager和GridView滑动起来,事件冲突的问题。
- Git 应用参考
- hdoj4937Lucky Number