亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么我的 go 頻道被屏蔽了?

為什么我的 go 頻道被屏蔽了?

Go
素胚勾勒不出你 2021-07-30 17:04:56
似乎“復雜”( getC) 函數被阻塞了。我假設通道一旦被讀取就會被銷毀,因此我想知道如何sC與getC函數和main函數共享通道而不會陷入死鎖(當前片段)package mainfunc main() {//simple function and complex function/channel    sC := make(chan string)    go getS(sC)    cC := make(chan string)    go getC(sC, cC)//collect the functions result         s := <-sC//do something with `s`. We print but we may want to use it in a `func(s)`print(s)//after a while we do soemthing with `c`        c := <-cC    print(c)}func getS(sC chan string) {    s :=  " simple completed "    sC <- s}func getC(sC chan string, cC chan string) {//we do some complex stuff  print("complex is not complicated\n")//Now  we need the simple value so we try wait for the s channel.    s := <-sC    c := s + " more "    cC <- c //send complex value}
查看完整描述

3 回答

  • 3 回答
  • 0 關注
  • 195 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號