diff --git a/integration-sqs-to-lambda/Function.go b/integration-sqs-to-lambda/Function.go new file mode 100644 index 0000000..0b57043 --- /dev/null +++ b/integration-sqs-to-lambda/Function.go @@ -0,0 +1,28 @@ +package integration_sqs_to_lambda + +import ( + "fmt" + "github.com/aws/aws-lambda-go/events" + "github.com/aws/aws-lambda-go/lambda" +) + +func handler(event events.SQSEvent) error { + for _, record := range event.Records { + err := processMessage(record) + if err != nil { + return err + } + } + fmt.Println("done") + return nil +} + +func processMessage(record events.SQSMessage) error { + fmt.Printf("Processed message %s\n", record.Body) + // TODO: Do interesting work based on the new message + return nil +} + +func main() { + lambda.Start(handler) +} diff --git a/integration-sqs-to-lambda/snippet-data.json b/integration-sqs-to-lambda/snippet-data.json index 894d8f1..45d4a89 100644 --- a/integration-sqs-to-lambda/snippet-data.json +++ b/integration-sqs-to-lambda/snippet-data.json @@ -3,7 +3,7 @@ "description": "Sample Amazon SQS function code", "type": "Integration", "services": ["lambda", "sqs"], - "languages": ["Node", ".NET", "TypeScript", "Java","Python"], + "languages": ["Node", ".NET", "TypeScript", "Java","Python","Go"], "tags": [], "introBox": { "headline": "How it works", @@ -74,6 +74,17 @@ "language": "py" } ] + }, + { + "id": "Go", + "title": "Usage Example with Golang:", + "description": "Sample Amazon SQS function code using Golang without batch item handling.", + "snippets": [ + { + "snippetPath": "Function.go", + "language": "go" + } + ] } ] }