Skip to content

Commit

Permalink
i1494 passing opts to attributevalue marshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
radutopala committed Nov 13, 2021
1 parent fafd921 commit 26056f1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions feature/dynamodb/attributevalue/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,17 @@ type Marshaler interface {
//
// Marshal cannot represent cyclic data structures and will not handle them.
// Passing cyclic structures to Marshal will result in an infinite recursion.
func Marshal(in interface{}) (types.AttributeValue, error) {
return NewEncoder().Encode(in)
func Marshal(in interface{}, optFns ...func(*EncoderOptions)) (types.AttributeValue, error) {
return NewEncoder(optFns...).Encode(in)
}

// MarshalMap is an alias for Marshal func which marshals Go value type to a
// map of AttributeValues. If the in parameter does not serialize to a map, an
// empty AttributeValue map will be returned.
//
// This is useful for APIs such as PutItem.
func MarshalMap(in interface{}) (map[string]types.AttributeValue, error) {
av, err := NewEncoder().Encode(in)
func MarshalMap(in interface{}, optFns ...func(*EncoderOptions)) (map[string]types.AttributeValue, error) {
av, err := NewEncoder(optFns...).Encode(in)

asMap, ok := av.(*types.AttributeValueMemberM)
if err != nil || av == nil || !ok {
Expand All @@ -198,8 +198,8 @@ func MarshalMap(in interface{}) (map[string]types.AttributeValue, error) {
// MarshalList is an alias for Marshal func which marshals Go value
// type to a slice of AttributeValues. If the in parameter does not serialize
// to a slice, an empty AttributeValue slice will be returned.
func MarshalList(in interface{}) ([]types.AttributeValue, error) {
av, err := NewEncoder().Encode(in)
func MarshalList(in interface{}, optFns ...func(*EncoderOptions)) ([]types.AttributeValue, error) {
av, err := NewEncoder(optFns...).Encode(in)

asList, ok := av.(*types.AttributeValueMemberL)
if err != nil || av == nil || !ok {
Expand Down

0 comments on commit 26056f1

Please sign in to comment.