1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-05 03:30:18 +00:00

golint fixes

This commit is contained in:
Eyal Post
2017-04-30 19:28:26 +03:00
parent cfb2f68dd6
commit 1b8f05cef1
6 changed files with 27 additions and 13 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/astaxie/beego/logs"
)
// ConvertParams converts http method params to values that will be passed to the method controller as arguments
func ConvertParams(methodParams []*MethodParam, methodType reflect.Type, ctx *beecontext.Context) (result []reflect.Value) {
result = make([]reflect.Value, 0, len(methodParams))
for i := 0; i < len(methodParams); i++ {
@ -55,15 +56,14 @@ func getParamValue(param *MethodParam, ctx *beecontext.Context) string {
func parseValue(param *MethodParam, paramValue string, paramType reflect.Type) (result reflect.Value, err error) {
if paramValue == "" {
return reflect.Zero(paramType), nil
} else {
parser := getParser(param, paramType)
value, err := parser.parse(paramValue, paramType)
if err != nil {
return result, err
}
return safeConvert(reflect.ValueOf(value), paramType)
}
parser := getParser(param, paramType)
value, err := parser.parse(paramValue, paramType)
if err != nil {
return result, err
}
return safeConvert(reflect.ValueOf(value), paramType)
}
func safeConvert(value reflect.Value, t reflect.Type) (result reflect.Value, err error) {