jcb*_*lkr 31

您需要在请求中添加内容类型.

http.PostForm
func PostForm(url string, data url.Values) (resp *Response, err error) {
    return DefaultClient.PostForm(url, data)
}
PostForm
func (c *Client) PostForm(url string, data url.Values) (resp *Response, err error) {
    return c.Post(url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode()))
}
Post"application/x-www-form-urlencoded"bodyType
func (c *Client) Post(url string, bodyType string, body io.Reader) (resp *Response, err error) {
    req, err := NewRequest("POST", url, body)
    if err != nil {
        return nil, err
    }
    req.Header.Set("Content-Type", bodyType)
    return c.doFollowingRedirects(req, shouldRedirectPost)
}

所以你的问题的解决方案是添加

req.Header.Set("Content-Type", "application/x-www-form-urlencoded")