title: How to read gzipped data from http response in Golang
body: <p>I have a http response which is gzipped.</p>
  
  <pre><code>resp, err := client.Do(req)
      if err != nil {
          return "", err
      }
  
      defer resp.Body.Close()
  
      if resp.StatusCode == http.StatusOK {
          var buf bytes.Buffer
  
  
      }
  </code></pre>
  
  <p>How can I ungzipped it and parse it into my struct?</p>
  
  <p>I saw a question like this:
  <a href="https://stackoverflow.com/questions/13130341/reading-gzipped-http-response-in-go">Reading gzipped HTTP response in Go</a></p>
  
  <p>but it output the response into a standard output. Also the example runs into error, the </p>
  
  <pre><code>reader, err = gzip.NewReader(response.Body)
  </code></pre>
  
  <p>returns err as "EOF". How can I debug this?</p>