You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DecodeCustomTypeFunc should be not func([]string) (interface{}, error), may be func(reflect.Type,[]string) (interface{}, error) will be better.
also. EncodeCustomTypeFunc: func(x interface{}) ([]string, error) -> func(t reflect.Type, x interface{}) ([]string, error).
get the match reflect.Type. the custom type parse function can do more thing.
Code sample, to showcase or reproduce:
example below:
I want to parser id=1,2,3 to []int or []CustomInt or more.
Package version eg. v4:
Issue, Question or Enhancement:
DecodeCustomTypeFunc
should be notfunc([]string) (interface{}, error)
, may befunc(reflect.Type,[]string) (interface{}, error)
will be better.also.
EncodeCustomTypeFunc
:func(x interface{}) ([]string, error)
->func(t reflect.Type, x interface{}) ([]string, error)
.get the match
reflect.Type
. the custom type parse function can do more thing.Code sample, to showcase or reproduce:
example below:
I want to parser
id=1,2,3
to[]int
or[]CustomInt
or more.I have to register twice. if decoder.go#L191 pass the
reflect.Type
to custom type parser function, we can register in one line.if
DecodeCustomTypeFunc
isfunc(reflect.Type,[]string) (interface{}, error)
, we can simple do below:Is there any other better solution?
The text was updated successfully, but these errors were encountered: