title: Accessing Uploaded Files in Golang
body: <p>I'm having issues with accessing files i upload w/ golang. I'm really new to the language and have gone through more than a few attempts-- can't find any answers to this online either.</p>
  
  <p>What am i doing wrong? In this code, i never get to the block where it lists the  # of files uploaded.</p>
  
  <pre><code>func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Println("handling req...")
  
    if r.Method =="GET"{
      fmt.Println("GET req...")
  
    } else {
  
      //parse the multipart stuff if there
      err := r.ParseMultipartForm(15485760)
  
      //
      if err == nil{
          form:=r.MultipartForm
          if form==nil {
              fmt.Println("no files...")
  
          } else {
              defer form.RemoveAll()
              // i never see this actually occur
              fmt.Printf("%d files",len(form.File))
          }
      } else {
          http.Error(w,err.Error(),http.StatusInternalServerError)
          fmt.Println(err.Error())
      }
    }
  
    //fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
    fmt.Println("leaving...")
  }
  </code></pre>
  
  <h3>Update</h3>
  
  <p>I was able to get the above code to work. Which is great. The answer below shows how to do it async, which may be a better code sample than mine.</p>