I'm trying to load data from Lambda using Golang into DynamoDB, however the marshalling method is just generating empty items. I have a type struct defined as below...
type Flight struct {
id string
destination string
airline string
time string
latest string
}
I am then populating a slice as below.....
func PutToDynamo(Flights []Flight, kind string) {
Flights := []Flight{}
for _, row := range rows {
columns := row.FindAll("td")
f := columns[0].Text() //all these are strings
a := columns[1].Text()
i := columns[2].Text()
t := columns[4].Text()
l := columns[5].Text()
flight := Flight{
id: i,
destination: f,
airline: a,
time: t,
latest: l,
}
Flights = append(Flights, flight)
Which I then try and load into DynamoDB.
func PutToDynamo(flights []Flight, kind string) {
for _, flight := range flights {
av, err := dynamodbattribute.MarshalMap(flight)
input := &dynamodb.PutItemInput{
Item: av,
TableName: aws.String("flights"),
}
_, err = svc.PutItem(input)
fmt.Println("FLIGHT: ", input.GoString())
If I print flight, I can see all the information I expect. However, input.GoString() is just returning the below...
{
Item: {
},
TableName: "flights"
}
and I get an error thrown from DynamoDB in lambda.
ValidationException: One or more parameter values were invalid: Missing the key id in the item
Any ideas?? I've tried putting json:"id"
etc in the struct, but no difference.
Thanks!