GO語言"net/url"包中"Values"類型的用法及代碼示例。
值將字符串鍵映射到值列表。它通常用於查詢參數和表單值。與 http.Header 映射不同,Values 映射中的鍵區分大小寫。
用法:
type Values map[string][]string
例子:
package main
import (
"fmt"
"net/url"
)
func main() {
v := url.Values{}
v.Set("name", "Ava")
v.Add("friend", "Jess")
v.Add("friend", "Sarah")
v.Add("friend", "Zoe")
// v.Encode() == "name=Ava&friend=Jess&friend=Sarah&friend=Zoe"
fmt.Println(v.Get("name"))
fmt.Println(v.Get("friend"))
fmt.Println(v["friend"])
}
輸出:
Ava Jess [Jess Sarah Zoe]
相關用法
- GO Values.Get用法及代碼示例
- GO Values.Set用法及代碼示例
- GO Values.Has用法及代碼示例
- GO Values.Del用法及代碼示例
- GO Values.Add用法及代碼示例
- GO Values.Encode用法及代碼示例
- GO Value用法及代碼示例
- GO Value.FieldByIndex用法及代碼示例
- GO ValidString用法及代碼示例
- GO Valid用法及代碼示例
- GO ValidRune用法及代碼示例
- GO Val用法及代碼示例
- GO Varint用法及代碼示例
- GO PutUvarint用法及代碼示例
- GO Scanner.Scan用法及代碼示例
- GO LeadingZeros32用法及代碼示例
- GO NewFromFiles用法及代碼示例
- GO Regexp.FindString用法及代碼示例
- GO Time.Sub用法及代碼示例
- GO Regexp.FindAllIndex用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Values。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。