goland 实现 http post

180it 2023-02-23 PM 632℃ 0条
package main
import (
    "fmt"
    "strings"
    "io/ioutil"
    "net/http"

)

func httpPost() {
    resp, err := http.Post("http://www.xxxx.com/api/httpdclient2/","application/x-www-form-urlencoded", strings.NewReader("id=test&data=ab123123"))
    if err != nil {
        fmt.Println(err)
    }
    defer resp.Body.Close()
    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        // handle error
    }
    fmt.Println(string(body))
}


func main() {
  httpPost()

}
支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

goland 实现 http post