Skip to content

Commit 69a3f40

Browse files
author
Jason Sia
committed
added go snippet for integration-sqs-to-lambda
1 parent 218e553 commit 69a3f40

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

integration-sqs-to-lambda/Function.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package integration_sqs_to_lambda
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"github.com/aws/aws-lambda-go/events"
7+
"github.com/aws/aws-lambda-go/lambda"
8+
)
9+
10+
func handler(ctx context.Context, event events.SQSEvent) error {
11+
for _, record := range event.Records {
12+
err := processMessage(record)
13+
if err != nil {
14+
return err
15+
}
16+
}
17+
fmt.Println("done")
18+
return nil
19+
}
20+
21+
func processMessage(record events.SQSMessage) error {
22+
fmt.Printf("Processed message %s\n", record.Body)
23+
// TODO: Do interesting work based on the new message
24+
return nil
25+
}
26+
27+
func main() {
28+
lambda.Start(handler)
29+
}

integration-sqs-to-lambda/snippet-data.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Sample Amazon SQS function code",
44
"type": "Integration",
55
"services": ["lambda", "sqs"],
6-
"languages": ["Node", ".NET", "TypeScript", "Java","Python"],
6+
"languages": ["Node", ".NET", "TypeScript", "Java","Python","Golang"],
77
"tags": [],
88
"introBox": {
99
"headline": "How it works",
@@ -74,6 +74,17 @@
7474
"language": "py"
7575
}
7676
]
77+
},
78+
{
79+
"id": "Golang",
80+
"title": "Usage Example with Golang:",
81+
"description": "Sample Amazon SQS function code using Golang without batch item handling.",
82+
"snippets": [
83+
{
84+
"snippetPath": "Function.py",
85+
"language": "go"
86+
}
87+
]
7788
}
7889
]
7990
}

0 commit comments

Comments
 (0)