title: Using Goroutines for background work inside an http handler
body: <p>I thought I'd found an easy way to return an http response immediately then do some work in the background without blocking. However, this doesn't work.  </p>
  
  <pre><code>func MyHandler(w http.ResponseWriter, r *http.Request) {
      //handle form values
      go doSomeBackgroundWork() // this will take 2 or 3 seconds
      w.WriteHeader(http.StatusOK)
  }
  </code></pre>
  
  <p>It works the first time--the response is returned immediately and the background work starts. However, any further requests hang until the background goroutine completes. Is there a better way to do this, that doesn't involve setting up a message queue and a separate background process.</p>