【发布时间】:2020-06-20 03:52:47
【问题描述】:
我有以下结构:
type User struct {
ID string `json:"id"`
Name string `json:"name"`
LastName string `json:"lastName"`
User string `json:"user"`
Password string `json:"password"`
Vehicles []Vehicle `json:"vehicles"`
}
type Vehicle struct {
Plate string `json:"plate"`
}
我想在我的 DynamoDB 中存储一组车辆。我做了一些研究,发现我应该使用以下代码:
input := &dynamodb.PutItemInput{
TableName: aws.String(tableUsers),
Item: map[string]*dynamodb.AttributeValue{
"id": {
S: aws.String(fmt.Sprintf("%v", uuid)),
},
"name": {
S: aws.String(user.Name),
},
"lastName": {
S: aws.String(user.LastName),
},
"user": {
S: aws.String(user.User),
},
"password": {
S: aws.String(user.Password),
},
"vehicles": {
L: [{
M: {
"plate": {S: aws.String("test")},
},
}],
},
},
}
但我一直有语法错误:
L: [{
M: {
"plate": {S: aws.String("test")},
},
}],
我做错了什么?
【问题讨论】:
标签: amazon-web-services go amazon-dynamodb