git Address: https://github.com/LeeDF/paramParse
Http.Request focus for analytical parameters, and return an error
Currently supports commonly used data types, new types can be added
Usage is very simple
welcome Tucao
example:
func Hello(w http.ResponseWriter, r *http.Request) { where ( paramInt64 int64 paramInt32 int32 paramStr string ) P := paramParse.NewParseRequest(r) Into the reference @: When a pointer variable, a form key, the default value, the default value is nil, equivalent required P.Int64Val(¶mInt64, "paramInt64", nil) P.Int32Val(¶mInt32, "paramInt32", "0") P.Str32Val(¶mStr, "paramInt32", nil) if ok := P.DoParse(); !ok { fmt.Printf("error parse form fail :%s", P.Err.Error()) return } }