mirror of
https://github.com/go-kratos/kratos.git
synced 2025-03-17 21:07:54 +02:00
fix: using rv directly (#1213)
This commit is contained in:
parent
b6d005b21e
commit
97222012e4
@ -39,7 +39,7 @@ func (codec) Marshal(v interface{}) ([]byte, error) {
|
||||
|
||||
func (codec) Unmarshal(data []byte, v interface{}) error {
|
||||
rv := reflect.ValueOf(v)
|
||||
for rv.Kind() == reflect.Ptr {
|
||||
for rv := rv; rv.Kind() == reflect.Ptr; {
|
||||
if rv.IsNil() {
|
||||
rv.Set(reflect.New(rv.Type().Elem()))
|
||||
}
|
||||
@ -47,7 +47,7 @@ func (codec) Unmarshal(data []byte, v interface{}) error {
|
||||
}
|
||||
if m, ok := v.(proto.Message); ok {
|
||||
return UnmarshalOptions.Unmarshal(data, m)
|
||||
} else if m, ok := reflect.Indirect(reflect.ValueOf(v)).Interface().(proto.Message); ok {
|
||||
} else if m, ok := reflect.Indirect(rv).Interface().(proto.Message); ok {
|
||||
return UnmarshalOptions.Unmarshal(data, m)
|
||||
}
|
||||
return json.Unmarshal(data, v)
|
||||
|
Loading…
x
Reference in New Issue
Block a user