Skip to content

Commit

Permalink
skip structInfo for non-structs
Browse files Browse the repository at this point in the history
  • Loading branch information
guregu committed May 5, 2024
1 parent b2544f3 commit a7bdc72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func marshal(v interface{}, flags encodeFlags) (*dynamodb.AttributeValue, error)
if err != nil {
return nil, err
}
enc, err := def.encodeType(rt, flags, nil)
enc, err := def.encodeType(rt, flags, def.info)
if err != nil {
return nil, err
}
Expand Down
8 changes: 8 additions & 0 deletions reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ func (info *structInfo) findZero(rt reflect.Type) func(reflect.Value) bool {
}

func (def *typedef) structInfo(rt reflect.Type, parent *structInfo) (*structInfo, error) {
rti := rt
for rti.Kind() == reflect.Pointer {
rti = rti.Elem()
}
if rti.Kind() != reflect.Struct {
return nil, nil
}

info := &structInfo{
root: rt,
parent: parent,
Expand Down

0 comments on commit a7bdc72

Please sign in to comment.