直接上例子吧:
func time_GET(w http.ResponseWriter, r *http.Request) {u, _ := url.Parse(r.URL.String())values, _ := url.ParseQuery(u.RawQuery)fmt.Println(u) // /time?a=111&b=1212424fmt.Println(u.RawQuery) // a=111&b=1212424fmt.Println(values) // map[a:[111] b:[1212424]]fmt.Println(values["a"]) //[111]fmt.Println(values["b"]) //[1212424]...
}...输入URL:http://localhost:8080/time?aaa=111&b=1212424程序输出:
/time?a=111&b=1212424
a=111&b=1212424
map[a:[111] b:[1212424]]
[111]
[1212424]