AWS SDK for Go
Developer Guide

Deleting an Amazon DynamoDB Table Item

The following example uses the DynamoDBUpdateItem operation to delete the item with the year 2015 and title The Big New Movie from the Movies table in the us-west-2 region.

Create the file dynamodb_update_item.go. Add the following statements to import the Go and AWS SDK for Go packages used in the example.

import ( "fmt" "" "" "" )

Initialize the session that the SDK uses to credentials from the shared credentials file ~/.aws/credentials, and create a new DynamoDB service client.

sess, err := session.NewSession(&aws.Config{ Region: aws.String("us-west-2")}, ) // Create DynamoDB client svc := dynamodb.New(sess)

Call DeleteItem to delete the item from the table. If we encounter an error, print the error message. Otherwise, display a message that the item was deleted.

input := &dynamodb.DeleteItemInput{ Key: map[string]*dynamodb.AttributeValue{ "year": { N: aws.String("2015"), }, "title": { S: aws.String("The Big New Movie"), }, }, TableName: aws.String("Movies"), } _, err = svc.DeleteItem(input) if err != nil { fmt.Println("Got error calling DeleteItem") fmt.Println(err.Error()) return } fmt.Println("Deleted 'The Big New Movie' (2015)")

See the complete example on GitHub.