问题背景
- http请求 然后使用 json.Unmarshal
原因
- The server is sending you a UTF-8 text string with a Byte Order Mark (BOM). The BOM identifies that the text is UTF-8 encoded, but it should be removed before decoding.
解决
在unmarshal之前将服务器返回的body处理一下
body = bytes.TrimPrefix(body, []byte("\xef\xbb\xbf")) // Or []byte{239, 187, 191}