go基本语法:channel未关闭遍历结束后会报错deadlock
生活随笔
收集整理的這篇文章主要介紹了
go基本语法:channel未关闭遍历结束后会报错deadlock
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
如果將其Close掉,就不會(huì)報(bào)錯(cuò)
func test1() {intChan = make(chan int, 3)intChan <- 11intChan <- 22intChan <- 33// 如果管道不關(guān)閉,遍歷管道結(jié)束后會(huì)報(bào)錯(cuò):deadlock!// close(intChan)for num := range intChan {fmt.Println(num)} }總結(jié)
以上是生活随笔為你收集整理的go基本语法:channel未关闭遍历结束后会报错deadlock的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【资讯】CloudBase Framew
- 下一篇: go ...打散切片