aws-go-sqs is a SQS library built with aws/aws-sdk-go.
- We have v1 branch so you can import it from
gopkg.in/nabeken/aws-go-sqs.v1
. - We have v2 branch so you can import it from
gopkg.in/nabeken/aws-go-sqs.v2
.
Since I've add API that I needed to this library, it is not completed but still useful.
See more examples in GoDoc.
import (
"log"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/sqs"
"github.com/nabeken/aws-go-sqs/queue"
"github.com/nabeken/aws-go-sqs/queue/option"
)
// Create SQS instance
s := sqs.New(&aws.Config{Region: aws.String("ap-northeast-1")})
// Create Queue instance
q, err := queue.New(s, "example-queue-name")
if err != nil {
log.Fatal(err)
}
// MessageAttributes
attrs := map[string]interface{}{
"ATTR1": "STRING!!",
"ATTR2": 12345,
}
if err := q.SendMessage("MESSAGE BODY", option.MessageAttributes(attrs)); err != nil {
log.Fatal(err)
}
log.Print("successed!")
I've add some integration tests in queue/queue_test.go
.
If you want to run the tests, you MUST create a decicated queue for the tests. The test suite issues PurgeQueue in teardown.
You can specify the name in environment variable.
$ cd queue
$ export TEST_SQS_QUEUE_NAME=aws-go-sqs-test
$ go test -v -tags debug
If you specify a debug tag, you get all HTTP request and response in stdout.