I'm reading gzip data from a http request like this:
gzr, err := gzip.NewReader(resp.Body)
handle(err)
And then conservatively allocating a slice for the unzipped data.
cl := resp.Header.Get("Content-Length")
icl, err := strconv.Atoi(cl)
handle(err)
ubs := make([]byte, icl*3)
And finally trimming the slice after reading
_, err = gzr.Read(ubs)
ubs = bytes.TrimRightFunc(ubs, sliceFunc)
Is there a better way to do this ?