Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
binbin committed Nov 15, 2021
1 parent 45e913a commit 8e8d280
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
7 changes: 0 additions & 7 deletions codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,3 @@ func ConvertSliceValueType(destTyp reflect.Type, v reflect.Value) (reflect.Value

return sl, nil
}

// PackPtrInterface pack interface struct to get the interface pointer
func PackPtrInterface(s interface{}, value reflect.Value) interface{} {
vp := reflect.New(reflect.TypeOf(s))
vp.Elem().Set(value)
return vp.Interface()
}
6 changes: 1 addition & 5 deletions encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,7 @@ func (e *Encoder) Encode(v interface{}) error {
switch t.Kind() {
case reflect.Struct:
vv := reflect.ValueOf(v)
if vv.Kind() != reflect.Ptr {
v = PackPtrInterface(v, vv)
} else {
vv = UnpackPtr(vv)
}
vv = UnpackPtr(vv)
if !vv.IsValid() {
e.buffer = EncNull(e.buffer)
return nil
Expand Down

0 comments on commit 8e8d280

Please sign in to comment.