You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gorequest/params.go

51 lines
913 B

2 years ago
package gorequest
2 years ago
// Params 参数
2 years ago
type Params map[string]interface{}
2 years ago
// NewParams 新建参数
2 years ago
func NewParams() Params {
P := make(Params)
return P
}
2 years ago
// NewParamsWith 参数使用
2 years ago
func NewParamsWith(params ...Params) Params {
p := make(Params)
for _, v := range params {
p.SetParams(v)
}
return p
}
2 years ago
// Set 设置参数
2 years ago
func (p Params) Set(key string, value interface{}) {
p[key] = value
}
2 years ago
// SetParams 批量设置参数
2 years ago
func (p Params) SetParams(params Params) {
for key, value := range params {
p[key] = value
}
}
5 months ago
// Get 获取参数
func (p Params) Get(key string) interface{} {
return p[key]
2 years ago
}
2 years ago
// DeepCopy 深度复制
func (p *Params) DeepCopy() map[string]interface{} {
targetMap := make(map[string]interface{})
// 从原始复制到目标
for key, value := range *p {
targetMap[key] = value
}
// 重新申请一个新的map
*p = map[string]interface{}{}
return targetMap
}