1 Answer
- Newest
- Most votes
- Most comments
0
【以下的回答经过翻译处理】 这个错误很可能是在GetItem
调用中发送了非主键属性导致的。当使用MarshalMap
时,它会在键对象中包括所有其他属性的空值。
你可以手动构建键,例如:
Key: map[string]*dynamodb.AttributeValue{
"userId": {
S: aws.String("2323"),
},
"username": {
S: aws.String("The Big New Movie"),
},
},
或者在结构体字段上添加omitempty
,当它们没有值时,将这些属性从编组映射中排除,例如:
type Movie struct {
Year int `json:"year,omitempty"`
Title string `json:"title,omitempty"`
[...]
}
Relevant content
- asked a year ago
- Accepted Answerasked 10 months ago
- Accepted Answerasked 2 months ago
- AWS OFFICIALUpdated 2 years ago