Stop a blocking goroutine : <p>How can I kill a goroutine which is blocking. An idea is that returning from the host function would be a solution but I'm not sure if this kills the goroutine or not.</p>

<pre><code>func myFunc() int {
   c := make(&lt;-chan int)
   go func(){
      for i := range c {
      // do stuff
      }
   }()
   return 0 // does this kills the inner goroutine?
}
</code></pre>

<p>Is there a more nice solution? For example it would be nice that something like this work but because of the blocking for it doesn't:</p>

<pre><code>func myFunc() int {
   c := make(&lt;-chan int)
   closeChan := make(chan int)
   go func() {
      select {
      case close := &lt;-closeChan:
         return 0
      default:
         for i := range c {
            // do stuff
         }
      }
   }()
   closeChan&lt;-0
   // other stuff
}
</code></pre>
