title: How to check if ResponseWriter has been written
body: <p>Using Golang's <a href="https://golang.org/pkg/net/http/" rel="nofollow">net/http</a> package, how can I check if the <code>ResponseWriter</code> has been written to? I am receiving the following error message:</p>
  
  <blockquote>
    <p>http: multiple response.WriteHeader calls</p>
  </blockquote>
  
  <p>Of course I can return booleans and such from my functions indicating weather I wrote to the <code>ResponseWriter</code> with a redirect or something, which I tried, but surely I am able to check if the <code>ResponseWriter</code> has been written to before I write to it with an easy method.</p>
  
  <p>I am looking for a function that would look something like the following which I can use before I write to the <code>ResponseWriter</code>:</p>
  
  <pre><code>if w.Header().Get("Status-Code") == "" {
      http.Redirect(w, r, "/", http.StatusSeeOther)
  } else {
      fmt.Println("Response Writer has already been written to.")
  }
  </code></pre>
  
  <p>The code above doesn't seem to work... anyone have any idea how to check if the <code>ResponseWriter</code> has been written to or not?</p>