Skip to content

Commit

Permalink
use reflect.Value directly
Browse files Browse the repository at this point in the history
  • Loading branch information
RangelReale committed Jul 8, 2023
1 parent f485302 commit a1ca14f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion decode_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (d *Decoder[IT, DC]) decodeInputFromStructInfo(input IT, si *structInfo, da
}
}

err := d.decodeStruct(si, input, data, decodeOptions)
err := d.decodeStruct(si, input, reflect.ValueOf(data), decodeOptions)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions decode_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

// decodeStruct uses the structInfo to decode the input to the struct.
func (d *Decoder[IT, DC]) decodeStruct(si *structInfo, input IT, data interface{}, decodeOptions DecodeOptions[IT, DC]) error {
dataValue := reflectValueElem(reflect.ValueOf(data))
func (d *Decoder[IT, DC]) decodeStruct(si *structInfo, input IT, dataValue reflect.Value, decodeOptions DecodeOptions[IT, DC]) error {
dataValue = reflectValueElem(dataValue)
if err := si.checkSameType(dataValue.Type()); err != nil {
return err
}
Expand All @@ -32,7 +32,7 @@ func (d *Decoder[IT, DC]) decodeStruct(si *structInfo, input IT, data interface{
case OperationRecurse:
// recurse into inner struct
reflectEnsurePointerValue(&fieldValue)
if err := d.decodeStruct(sifield, input, fieldValue.Addr().Interface(), decodeOptions); err != nil {
if err := d.decodeStruct(sifield, input, fieldValue, decodeOptions); err != nil {
return err
}
dataWasSet = true
Expand Down

0 comments on commit a1ca14f

Please sign in to comment.