Today I wrote a script with go and returned the result like this:

Did for a long time, thought that the return is not UTF8 encoding format, and then found a GBK library to parse

And then it’s still garbled.

Finally, I googled it.

I found it because WHEN I sent the request, I used gzip compression.

So the call’s request return results are also gzip compressed.

Because go HTTP library does not automatically decompress cause!

Manual decompression solves this problem:

code

reader, _ := gzip.NewReader(res.Body)
result, _ := ioutil.ReadAll(reader)
Copy the code