http NewRequest作为代理proxy转发的时候,突然获取不到参数.emmm,记录一下
package main import ( "fmt" "net/http" "net/url" ) func MyRequest(remoteUrl string, queryValues url.Values) { // client := &http.Client{} uri, err := url.Parse(remoteUrl) if err != nil { fmt.Println(err.Error()) return } if queryValues != nil { values := uri.Query() if values != nil { for k, v := range values { queryValues[k] = v } } uri.RawQuery = queryValues.Encode() } fmt.Println(uri.String()) req, err := http.NewRequest("GET", uri.String(), nil) if err != nil { fmt.Println(err.Error()) } fmt.Println(req.URL) } func main() { data := make(url.Values) data["host"] = []string{"192.168.88.59"} data["name"] = []string{"admin"} MyRequest("htutp://127.0.0.1:8080/", data) }