mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-07 23:02:12 +02:00
fix nil target (#774)
This commit is contained in:
parent
0b93bef031
commit
32f7322b82
@ -24,7 +24,7 @@ func (codec) Marshal(v interface{}) ([]byte, error) {
|
|||||||
func (codec) Unmarshal(data []byte, v interface{}) error {
|
func (codec) Unmarshal(data []byte, v interface{}) error {
|
||||||
rv := reflect.ValueOf(v)
|
rv := reflect.ValueOf(v)
|
||||||
for rv.Kind() == reflect.Ptr {
|
for rv.Kind() == reflect.Ptr {
|
||||||
if rv.IsNil() && rv.CanSet() {
|
if rv.IsNil() && rv.CanInterface() {
|
||||||
rv.Set(reflect.New(rv.Type().Elem()))
|
rv.Set(reflect.New(rv.Type().Elem()))
|
||||||
v = rv.Interface()
|
v = rv.Interface()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user