Skip to content
Get Started for Free
To improve reliability, we’ve moved to a single, authenticated LocalStack for AWS image that requires an auth token. For more details on plans and pricing, see our pricing page.

AWS Go

The AWS SDK for Go, like other AWS SDKs, lets you set the endpoint when creating resource clients, which is the preferred way of integrating the Go SDK with LocalStack.

The Go SDK has two major versions, each with their own way of specifying the LocalStack endpoint:

Here is an example of how to create an S3 Client from a Session with the endpoint set to LocalStack. Full examples for both SDK versions can be found in our samples repository.

package main
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/aws/credentials"
)
func main() {
// Initialize a session
sess, _ := session.NewSession(&aws.Config{
Region: aws.String("us-east-1"),
Credentials: credentials.NewStaticCredentials("test", "test", ""),
S3ForcePathStyle: aws.Bool(true),
Endpoint: aws.String("http://localhost:4566"),
})
// Create S3 service client
client := s3.New(sess)
// ...
}
Was this page helpful?