使用简化版本的http post请求会带来一个很莫名其妙的error :EOF
这里有一些解法:
将简化版 的http post改为,client.Do(request),并将request.Close设置为true。
client := &http.Client{} req,err := http.NewRequest(method,url,httpBody) // NOTE this !! req.Close = true req.Header.Set("Content-Type","application/json") req.SetBasicAuth("user","pass") resp,err := client.Do(req) if err != nil { // whatever } defer resp.Body.Close() response,err = IoUtil.ReadAll(resp.Body) if err != nil { // Whatever }原文链接:https://www.f2er.com/go/190275.html