title: How can I use 'time.After' and 'default' in Golang?
body: <p>I'm trying to understand a simple code of Golang routines:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "time"
  )
  
  func sleep(seconds int, endSignal chan&lt;- bool) {
      time.Sleep(time.Duration(seconds) * time.Second)
      endSignal &lt;- true
  }
  
  func main() {
      endSignal := make(chan bool, 1)
      go sleep(3, endSignal)
      var end bool
  
      for !end {
          select {
          case end = &lt;-endSignal:
              fmt.Println("The end!")
          case &lt;-time.After(5 * time.Second):
              fmt.Println("There's no more time to this. Exiting!")
              end = true
          }
      }
  
  }
  </code></pre>
  
  <p>That's fine, but Why I cannot use a simple default in this "select" block? Something like this:</p>
  
  <pre><code>for !end {
      select {
      case end = &lt;-endSignal:
          fmt.Println("The end.")
      case &lt;-time.After(4 * time.Second):
          fmt.Println("There's no more time to this. Exiting!")
          end = true
      default:
          fmt.Println("No end signal received.")
      }
  }
  </code></pre>
  
  <p>It gets this output:</p>
  
  <pre><code>❯ go run goroutines-timeout.go
  No end signal received!
  No end signal received!
  No end signal received!
  No end signal received!
  ...
  The end!
  </code></pre>
  
  <p>And I can't understand why.</p>