Background
I am trying to Unmarshal an item returned by dynamodb.GetItem
into an object, which type I do not know at that place.
For this I have a function emptyItemConstructor
which returns a new object t of the desired type.
Question
I have a function like this:
func GetItem(emptyItemConstructor func() interface{}) interface{} {
myItem := emptyItemConstructor()
fmt.Printf("Type is: %T
", myItem)
_ = dynamodbattribute.UnmarshalMap(item, &myItem)
fmt.Printf("Type now is: %T
", myItem)
}
and I am passing this function for emptyItemConstructor
:
func constructor() MyDynamoDBItemType {
return MyDynamoDBItemType{}
}
The output of the function is:
Type is: MyDynamoDBItemType
Type now is: map[string]interface
Why is UnmarshalMap changing the type of myItem?