Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么Golang http参数(URL.Query())是列表的映射?_Go - Fatal编程技术网

为什么Golang http参数(URL.Query())是列表的映射?

为什么Golang http参数(URL.Query())是列表的映射?,go,Go,当我们打电话时 r.URL.Query() 在Go中的http路由处理程序中,它返回一个map[string][]字符串。我想知道为什么它是一个列表,以及在发送请求时是否可以以某种方式使用此属性。它是一个列表,因为允许它在URL中发送同一查询字符串参数的多个副本,并且可以在请求中发送查询字符串参数 例如,对于像http://example.com/?foo=1&foo=2,Query()将返回: {"foo": ["1","2"]} 通过使用

当我们打电话时

r.URL.Query()

在Go中的http路由处理程序中,它返回一个map[string][]字符串。我想知道为什么它是一个列表,以及在发送请求时是否可以以某种方式使用此属性。

它是一个列表,因为允许它在URL中发送同一查询字符串参数的多个副本,并且可以在请求中发送查询字符串参数

例如,对于像
http://example.com/?foo=1&foo=2
Query()
将返回:

{"foo": ["1","2"]}
通过使用