Is it acceptable to use a golang struct return AND error return in a lambda triggered by SQS ?
- 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
Assessment
This issue has not been assessed yet.