title: How can I pause, or restart my go routine that is inside of my http handler func
body: <p>I have a http handlerFunc that establishes a websocket connection.<br />
  If I get a websocket message <code>start</code> then I fire off a goroutine that will stream down some text/paragraphs of a story to the client.</p>
  <p>Is it possible to stop a goroutine?</p>
  <p>I want to stop/pause the goroutine if a I get another message like <code>pause</code> or <code>stop</code>, I would like to stop that goroutine.   If I can't pause the goroutine, I would then like to know which sentence it was stopped at, and store that information somewhere so I can restart back at the same spot I stopped at.</p>
  <p>Is this possible?</p>
  <pre><code>http.HandleFunc(&quot;/streamStory&quot;, streamStory)
  log.Fatal(http.ListenAndServe(*addr, nil))
  
  func streamStory(w http.ResponseWriter, r *http.Request) {
      c, err := upgrader.Upgrade(w, r, nil)
      if err != nil {
          log.Print(&quot;upgrade:&quot;, err)
          return
      }
      defer c.Close()
      
  
      for {
          mt, message, err := c.ReadMessage()
          if err != nil {
              log.Println(&quot;read:&quot;, err)
              break
          }
          if message == &quot;start&quot; {
            go doSomething(c)
          }
  
      }
  }
  </code></pre>