title: How to properly stop the web-server that comes with Go sdk?
body: <p>What is the right way to shutdown the web-server that comes with the Go SDK?  </p>
  
  <p>Here's an example web service:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "net/http"
  )
  
  func handler(w http.ResponseWriter, r *http.Request) {
      fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
  }
  
  func main() {
      http.HandleFunc("/", handler)
      http.ListenAndServe(":8080", nil)
  }
  </code></pre>
  
  <p>That was pulled form here: <a href="https://golang.org/doc/articles/wiki/#tmp_3" rel="nofollow">https://golang.org/doc/articles/wiki/#tmp_3</a></p>
  
  <p>However, I'd like to tear down this server and have it drain off any currently running requests.  How is this done?</p>