1
0
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:
Tony Chen 2021-03-16 23:34:20 +08:00 committed by GitHub
parent 0b93bef031
commit 32f7322b82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,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 {
if rv.IsNil() && rv.CanSet() {
if rv.IsNil() && rv.CanInterface() {
rv.Set(reflect.New(rv.Type().Elem()))
v = rv.Interface()
}