title: Can I force termination a goroutine without waiting for it to return?
body: <p>Let me use an example:</p>
  
  <pre><code>func WaitForStringOrTimeout() (string, error) {
    my_channel := make(chan string)
    go WaitForString(my_channel)
  
    select {
    case found_string := &lt;-my_channel:
      return found_string, nil
    case  &lt;-time.After(15 * time.Minute):
      return nil, errors.New("Timed out waiting for string")
    }
  }
  </code></pre>
  
  <p>In this simple example, I have some function WaitForString which blocks for awhile and eventually may return a string. I want to wrap WaitForString with this code which either returns the same string or times out with an error.</p>
  
  <p>If a string is found quickly, is there still a goroutine running with a 15 minute sleep statement somewhere or is this garbage collected somehow?</p>
  
  <p>If the timeout occurs and a string is never found, is there still a goroutine running WaitForString, even though there are no other routines that could observe it's output? What if WaitForString allocates a lot of memory but never returns?</p>
  
  <p>Is there some way I can make WaitForString() become aware of the timeout occurring and give up?</p>