golang using timeouts with channels

后端 未结 4 1399
抹茶落季
抹茶落季 2020-12-30 03:32

I am using goroutines/channels to check if list of urls are reachable. Here is my code. This seems to always return true. Why is the timeout case not getting executed? The g

4条回答
  •  生来不讨喜
    2020-12-30 03:40

    change the line

    ch := make(chan bool, 1)
    

    to

    ch := make(chan bool)
    

    You did open a asynchronous (= non blocking) channel, but you need a blocking channel to get it work.

提交回复
热议问题