aws / aws/aws-lambda-go

Is it acceptable to use a golang struct return AND error return in a lambda triggered by SQS ?

Open
#425 3 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Go
Stars
3.8k
Forks
578
Avg merge
8h 18m
Merged PRs (30d)
1

Description

Hi,

https://docs.aws.amazon.com/lambda/latest/dg/with-sqs-create-package.html#with-sqs-example-deployment-pkg-go

Lambda return signature to SQS in the example is :

`func handler(ctx context.Context, sqsEvent events.SQSEvent) error {
`

Just a simple error return, with no struct.

However, to allow a lambda written in golang to provide more data when invoked outside of SQS, my code is returning an APIGatewayProxyResponse and an error. It is a feature of go to have multple return values, including an error.
I can invoke the lambda manually and see return values, rather than just nil, or have logs to go to Cloudwatch.

My interest in this is for testing - The lambda can return 'success data values or status', and an error for 'failure'.

`func handle(ctx context.Context, sqsEvent events.SQSEvent) (events.APIGatewayProxyResponse, error) {
`

This is all working (error returns to SQS not tested, but not causing a problem either, I will test).

Thanks,

Marc

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.