Answers:
根据定义,QueryString 位于URL中。您可以使用req.URL(doc)访问请求的URL 。URL对象具有一个返回类型的Query()方法(doc),该Values类型只是map[string][]stringQueryString参数的一个。
如果您要查找的是HTML表单提交的POST数据,那么(通常)这是请求正文中的键/值对。您的回答是正确的,您可以调用该字段ParseForm(),然后使用req.Formfield获取键-值对的映射,但是您也可以调用FormValue(key)以获取特定键的值。这ParseForm()在需要时调用,并获取值,而不管它们如何发送(即,在查询字符串中还是在请求正文中)。
req.URL.RawQuery?如果有帮助,则返回GET请求后的所有内容。
                    这是有关如何访问GET参数的更具体的示例。该Request对象有一个为您解析它们的方法,称为Query:
假设请求网址为http:// host:port / something?param1 = b
func newHandler(w http.ResponseWriter, r *http.Request) {
  fmt.Println("GET params were:", r.URL.Query())
  // if only one expected
  param1 := r.URL.Query().Get("param1")
  if param1 != "" {
    // ... process it, will be the first (only) if multiple were given
    // note: if they pass in like ?param1=¶m2= param1 will also be "" :|
  }
  // if multiples possible, or to process empty values like param1 in
  // ?param1=¶m2=something
  param1s := r.URL.Query()["param1"]
  if len(param1s) > 0 {
    // ... process them ... or you could just iterate over them without a check
    // this way you can also tell if they passed in the parameter as the empty string
    // it will be an element of the array that is the empty string
  }    
}
还要注意:“ Values映射中的键[即Query()返回值]区分大小写。”
Get方法仅在存在多个时才返回第一个,因此这是更多示例。有用的信息,谢谢!
                    这是一个简单的示例:
package main
import (
    "io"
    "net/http"
)
func queryParamDisplayHandler(res http.ResponseWriter, req *http.Request) {
    io.WriteString(res, "name: "+req.FormValue("name"))
    io.WriteString(res, "\nphone: "+req.FormValue("phone"))
}
func main() {
    http.HandleFunc("/example", func(res http.ResponseWriter, req *http.Request) {
        queryParamDisplayHandler(res, req)
    })
    println("Enter this in your browser:  http://localhost:8080/example?name=jenny&phone=867-5309")
    http.ListenAndServe(":8080", nil)
}
              有两种获取查询参数的方法:
在第二种情况下,必须小心,因为主体参数将优先于查询参数。有关获取查询参数的完整描述,请参见此处。
https://golangbyexample.com/net-http-package-get-query-params-golang
r.FormValue("id")用于获取查询参数,则无法通过cURL中的表单数据发送i(即,curl 0.0.0.0:8888 -d id=foobar将不起作用)。您必须通过查询参数(curl 0.0.0.0:8888?id=foobar)发送它。