Looks reasonable enough to me, but we still don’t know what happens other than that it’s not what you expect. What do you expect, and what does actually happen?
I am getting a response body of type gzip from the API. As resp.Body is a reader interface, I felt I should put that into the gunzip.NewReader to obtain a new decompressed json of type reader. My understanding was if I put this into the decoder with my struct, that would marshal the json into my structs. Unfortunately when I inspect the struct its empty. However, when I do a copy of the reader to stdio I can clearly see the data.
And you don’t get an error of any kind from the JSON unmarshal, and the data matches your expected format? What if you take that data from stdout, stick it in a bytes.Buffer and run the unmarshal on that?
There are no errors and when I step through with the debugger I dont see any errors. A person has offered some code on Stack Overflow and he said he tested it successfully, yet I still get the empty struct. I am running go 1.7 and im beginning to think this is a bug with the language.
The correct answer is available at Stack Overflow. This was a poor lack of understanding of Unmarshalling on my behalf. I’m not sure I fully understand, but I can at least work backwards now.
The solution can be seen here, thanks to Ezequiel Moreno.