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})
}
Can we provide a public function
MarshalStructfor 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: