title: How do I iterate over a go time.Tick channel?
body: <p>I'm having difficulty using <code>time.Tick</code>. I expect this code to print "hi" 10 times then quit after 1 second, but instead it hangs:</p>
  
  <pre><code>ticker := time.NewTicker(100 * time.Millisecond)
  time.AfterFunc(time.Second, func () {
      ticker.Stop()
  })
  
  for _ = range ticker.C {
      go fmt.Println("hi")
  }
  </code></pre>
  
  <p><a href="https://play.golang.org/p/1p6-ViSvma" rel="nofollow">https://play.golang.org/p/1p6-ViSvma</a></p>
  
  <p>Looking at the <a href="http://golang.org/src/time/tick.go?s=1319:1342#L35" rel="nofollow">source</a>, I see that the channel isn't closed when <code>Stop()</code> is called. In that case, what is the idiomatic way to iterate over the ticker channel?</p>