title: Go using timeouts with channels
body: <p>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 goal is to return false even if one of the urls is not reachable</p>
  
  <pre><code>import "fmt"
  import "time"
  
  func check(u string) bool {
      time.Sleep(4 * time.Second)
      return true
  }
  
  func IsReachable(urls []string) bool {
  
      ch := make(chan bool, 1)
      for _, url := range urls {
          go func(u string) {
              select {
              case ch &lt;- check(u):
              case &lt;-time.After(time.Second):
                  ch&lt;-false
              }
          }(url)
      }
      return &lt;-ch
  }
  func main() {
      fmt.Println(IsReachable([]string{"url1"}))
  }
  </code></pre>