Skip to content

Provide public MarshalStruct #182

Description

@liangxuuu

Can we provide a public function MarshalStruct for external calls, in case the caller just needs to add some extra fields to the marshal process but doesn't want to actually handle the marshal process himself?

For example:

// dynamodb table
type Item struct {
    PK string `dynamo:",hash"`
}

type User struct {
    Username string
    Email string
}

type UserItem struct {
    *Item
    *User
}

// We want to add PK automatically in the marshal process
func (u *User) MarshalDynamoItem() (map[string]*dynamodb.AttributeValue, error) {
    return dynamo.MarshalStruct(&UserItem{&Item{PK:"U#"+u.Username}, u})
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions