Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Migrating to DAX Go SDK V2

Focus mode
Migrating to DAX Go SDK V2 - Amazon DynamoDB

This migration guide will help you transition your existing DAX Go applications.

V1 DAX Go SDK usage

package main import ( "fmt" "os" "github.com/aws/aws-dax-go/dax" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/dynamodb" ) func main() { region := "us-west-2" endpoint := "dax://my-cluster.l6fzcv.dax-clusters.us-east-1.amazonaws.com" // Create session sess, err := session.NewSession(&aws.Config{ Region: aws.String(region), }) if err != nil { fmt.Printf("Failed to create session: %v\n", err) os.Exit(1) } // Configure DAX client cfg := dax.DefaultConfig() cfg.HostPorts = []string{endpoint} cfg.Region = region // Create DAX client daxClient, err := dax.New(cfg) if err != nil { fmt.Printf("Failed to create DAX client: %v\n", err) os.Exit(1) } defer daxClient.Close() // Don't forget to close the client // Create GetItem input input := &dynamodb.GetItemInput{ TableName: aws.String("TryDaxTable"), Key: map[string]*dynamodb.AttributeValue{ "pk": { N: aws.String("1"), }, "sk": { N: aws.String("1"), }, }, } // Make the GetItem call result, err := daxClient.GetItem(input) if err != nil { fmt.Printf("Failed to get item: %v\n", err) os.Exit(1) } // Print the result fmt.Printf("GetItem succeeded: %+v\n", result) }

V2 DAX Go SDK usage

package main import ( "context" "fmt" "os" "github.com/aws/aws-dax-go-v2/dax" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/dynamodb" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue" "github.com/aws/aws-sdk-go-v2/aws" ) func main() { ctx := context.Background() region := "us-west-2" endpoint := "dax://my-cluster.l6fzcv.dax-clusters.us-east-1.amazonaws.com" // Create DAX config config := dax.DefaultConfig() // Specify Endpoint and Region config.HostPorts = []string{endpoint} config.Region = region // Enabling logging config.LogLevel = utils.LogDebug // Create DAX client daxClient, err := dax.New(config) if err != nil { fmt.Printf("Failed to create DAX client: %v\n", err) os.Exit(1) } defer daxClient.Close() // Don't forget to close the client // Create key using attributevalue.Marshal for type safety pk, err := attributevalue.Marshal(fmt.Sprintf("%s_%d", keyPrefix, i)) if err != nil { return fmt.Errorf("error marshaling pk: %v", err) } sk, err := attributevalue.Marshal(fmt.Sprintf("%d", j)) if err != nil { return fmt.Errorf("error marshaling sk: %v", err) } // Create GetItem input input := &dynamodb.GetItemInput{ TableName: aws.String("TryDaxTable"), Key: map[string]types.AttributeValue{ "pk": pk, "sk": sk, }, } // Make the GetItem call result, err := daxClient.GetItem(ctx, input) if err != nil { fmt.Printf("Failed to get item: %v\n", err) os.Exit(1) } // Print the result fmt.Printf("GetItem succeeded: %+v\n", result) }

For more API usage details, see AWS samples.

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.