Skip to content

Instantly share code, notes, and snippets.

@ocakhasan
Created July 22, 2023 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ocakhasan/053c35a9f0e9a231bb7846b4d9cfa6db to your computer and use it in GitHub Desktop.
Save ocakhasan/053c35a9f0e9a231bb7846b4d9cfa6db to your computer and use it in GitHub Desktop.
Local SQS Queue Setup
package main
import (
"context"
"log"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/sqs"
)
type localResolver struct{}
func (l localResolver) ResolveEndpoint(service, region string, options ...interface{}) (aws.Endpoint, error) {
return aws.Endpoint{
URL: "http://localhost:9324",
SigningRegion: "eu-west-1",
}, nil
}
func main() {
cfg, err := config.LoadDefaultConfig(context.Background())
if err != nil {
log.Fatal(err)
}
cfg.EndpointResolverWithOptions = localResolver{}
sqsClient := sqs.NewFromConfig(cfg)
res, err := sqsClient.ListQueues(context.Background(), &sqs.ListQueuesInput{
MaxResults: aws.Int32(10),
NextToken: nil,
QueueNamePrefix: nil,
})
if err != nil {
log.Printf("error while listing the queues")
}
for _, queue := range res.QueueUrls {
log.Println(queue)
}
}
@ocakhasan
Copy link
Author

Code for the blog post of Local SQS Setup With Golang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment