title: How to retrieve a cookie in Go?
body: <p>I'm getting <code>undefined: msg</code> error on the line begining with <code>tmpl.Execute</code>. How are you supposed to retrieve cookies in Go?</p>
  
  <pre><code>func contact(w http.ResponseWriter, r *http.Request) {
      if r.Method == "POST" {
          r.ParseForm()
          for k, v := range r.Form {
              fmt.Println("k:", k, "v:", v)
          }
          http.SetCookie(w, &amp;http.Cookie{Name: "msg", Value: "Thanks"})
          http.Redirect(w, r, "/contact/", http.StatusFound)
      }
      if msg, err := r.Cookie("msg"); err != nil {
          msg := ""
      }
      tmpl, _ := template.ParseFiles("templates/contact.tmpl")
      tmpl.Execute(w, map[string]string{"Msg": msg})
  }
  </code></pre>