I wrote a simple code for gcm service:
httpReq, err := http.NewRequest(`POST`, `https://android.googleapis. com/gcm/send`, bytes.NewReader(jsonStr))
...
httpReq.Header.Set(`Authorization`, `key=`+gcmKey.Key)
httpReq.Header.Set(`Content-Type`, `application/json`)
...
But I checked my log after running this code, I found Do() replied an error:
Post https://android.googleapis.com/gcm/send: http: Request.ContentLength=326 with Body length 0
From the error, ContentLength=326, that means http.NewRequest() set the length correctly. And then I printed httpReq via Write() func, it has body definitely.
Anybody can help solve this?