Skip to content

Commit

Permalink
remove unused types JTypeMapper check & support default types.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mengchao.Lv1 authored and Mengchao.Lv1 committed Dec 2, 2023
1 parent 55bb412 commit d258c95
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions pixiu/pkg/client/dubbo/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,22 @@ type paramTypesOpt struct{}
// Action for paramTypesOpt override the other param types mapping/config.
// The val must be string(e.g. "int, object"), and will then assign to the target.(dubboTarget).Types
func (opt *paramTypesOpt) Action(target, val interface{}) error {
v, ok := val.(string)
if !ok {
return errors.New("The val type must be string")
}
types := strings.Split(v, ",")
dubboTarget, ok := target.(*dubboTarget)
if !ok {
return errors.New("Target is not dubboTarget in target parameter")
}
for i := range types {
trimType := strings.TrimSpace(types[i])
if len(trimType) == 0 {
continue
}
if _, ok = constant.JTypeMapper[trimType]; !ok {
return errors.Errorf("Types invalid %s", trimType)
// empty types for func like func()
var types []string
if v, ok := val.(string); ok {
if len(v) > 0 {
types = strings.Split(v, ",")
if !ok {
return errors.New("Target is not dubboTarget in target parameter")
}
for i := range types {
types[i] = strings.TrimSpace(types[i])
}
}
types[i] = trimType
}
dubboTarget.Types = types
return nil
Expand Down

0 comments on commit d258c95

Please sign in to comment.