为什么http.Header中的slice的长度返回0?

来自net / http的源代码。的定义http.Header是map[string][]string。正确的?


但是为什么要go run在下面的代码中得到结果:


0


2个


func main() {

    var header = make(http.Header)

    header.Add("hello", "world")

    header.Add("hello", "anotherworld")

    var t = []string {"a", "b"}

    fmt.Printf("%d\n", len(header["hello"]))

    fmt.Print(len(t))

}


精慕HU
浏览 166回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go