增加getuint64/32的方法
This commit is contained in:
@@ -223,6 +223,34 @@ func GetQueryFloat64(r *http.Request, key string, defaultValue float64) float64
|
||||
return floatValue
|
||||
}
|
||||
|
||||
func GetQueryUint64(r *http.Request, key string, defaultValue uint64) uint64 {
|
||||
value := r.URL.Query().Get(key)
|
||||
if value == "" {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
uintValue, err := strconv.ParseUint(value, 10, 64)
|
||||
if err != nil {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
return uintValue
|
||||
}
|
||||
|
||||
func GetQueryUint32(r *http.Request, key string, defaultValue uint32) uint32 {
|
||||
value := r.URL.Query().Get(key)
|
||||
if value == "" {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
uintValue, err := strconv.ParseUint(value, 10, 32)
|
||||
if err != nil {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
return uint32(uintValue)
|
||||
}
|
||||
|
||||
// GetFormValue 获取表单值(公共方法)
|
||||
// r: HTTP请求
|
||||
// key: 参数名
|
||||
|
||||
Reference in New Issue
Block a user