在與 DynamoDB 通信時,我一直在使用 Protobuf 進行對象定義。到目前為止,這些對象看起來像這樣:type Record struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Id string `protobuf:"bytes,2,opt,name=id,json=id,proto3" dynamodbav:"id,omitempty" json:"id,omitempty"` Name string `protobuf:"bytes,3,opt,name=name,json=name,proto3" dynamodbav:"name,omitempty" json:"name,omitempty"` OrgId string `protobuf:"bytes,4,opt,name=org_id,json=orgId,proto3" dynamodbav:"org_id,omitempty" json:"org_id,omitempty"` AccountId string `protobuf:"bytes,7,opt,name=account_id,json=accountId,proto3" dynamodbav:"account_id,omitempty" json:"account_id,omitempty"` Address string `protobuf:"bytes,9,opt,name=address,proto3" dynamodbav:"address,omitempty" json:"address,omitempty"` BillingTitle string `protobuf:"bytes,10,opt,name=billing_title,json=billingTitle,proto3" dynamodbav:"billing_title,omitempty" json:"billing_title,omitempty"`}這段代碼不會驚慌,我會看到 DynamoDB 中的值。但是,omitempty從所有標簽中刪除該子句后dynamodbav,我注意到現在失敗并出現以下錯誤:ValidationException: Invalid attribute value type status code: 400, request id: 6a626232-fcd4-4999-afe4-3df5769ce1b2我想使用默認值而不是前者,NULL: true但我沒有看到任何序列化選項。有沒有辦法在不實現 DynamoDB 封送器接口的情況下做到這一點?
Golang 中 DynamoDB 索引鍵的空字符串
慕碼人2483693
2022-10-10 19:31:58