用golang进行http请求类型多了,总结备忘一下。 1.普通的post\get请求 var r http.Request r.ParseForm() r.Form.Add("uuid", orderUUID) bodystr := strings.TrimSpace(r.Form.Encode()) request, err := http.NewRequest("GET", url, strings.NewReader(bodystr)) if err != nil { //TODO: }...
-
golang几种post方式
-
golang 利用http.Client POST数据
package main import ( "fmt" "io/ioutil" "net/http" "net/url" "strings" ) func main() { v := url.Values{} v.Set("huifu", "hello world") body := ioutil.NopCloser(strings.NewReader(v.Encode())) //把form数据编下码 client := &http.Client{} req, _ := http.NewReq...