title: How to print the bytes while the file is being downloaded ? -golang
body: <p>I'm wondering if it's possible to count and print the number of bytes downloaded while the file is being downloaded.</p>
  <pre><code>out, err := os.Create(&quot;file.txt&quot;)
  defer out.Close()
  if err != nil {
      fmt.Println(fmt.Sprint(err))
      panic(err)
  }
  resp, err := http.Get(&quot;http://example.com/zip&quot;)
  defer resp.Body.Close()
  if err != nil {
      fmt.Println(fmt.Sprint(err))
      panic(err)
  }
  
  n, er := io.Copy(out, resp.Body)
  if er != nil {
      fmt.Println(fmt.Sprint(err))
  }
  fmt.Println(n, &quot;bytes &quot;)
  </code></pre>