Building Lambda functions with Go
Go is implemented differently than other managed runtimes. Because Go compiles to native code, Lambda treats Go as a custom runtime. We recommend that you use the provided.al2023
or provided.al2
runtime to deploy Go functions to Lambda.
Go runtime support
The Go 1.x managed runtime for Lambda is based on the Amazon Linux AMI (AL1). Lambda will continue to support the Go 1.x managed runtime until maintenance support for the Amazon Linux AMI ends on December 31, 2023. If you're using the Go 1.x runtime, you must migrate your functions to provided.al2023
or provided.al2
. No code changes are required for this migration. The only required changes relate to how you build your deployment package and which runtime you use to create your function. For more information, see the deployment instructions for .zip packages and container images.
Go | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Name | Identifier | Operating system | Architectures | Deprecation (Phase 1) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Go 1.x |
|
Amazon Linux |
x86_64 |
Dec 31, 2023 |
The provided.al2023
and provided.al2
runtimes offer several advantages over go1.x
, including support for the arm64 architecture (AWS Graviton2 processors), smaller binaries, and slightly faster invoke times.
Custom | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Name | Identifier | Operating system | Architectures | Deprecation (Phase 1) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Custom Runtime |
|
Amazon Linux 2023 |
x86_64, arm64 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Custom Runtime |
|
Amazon Linux 2 |
x86_64, arm64 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Custom Runtime |
|
Amazon Linux |
x86_64 |
Dec 31, 2023 |
Tools and libraries
Lambda provides the following tools and libraries for the Go runtime:
-
AWS SDK for Go
: the official AWS SDK for the Go programming language. -
github.com/aws/aws-lambda-go/lambda
: The implementation of the Lambda programming model for Go. This package is used by AWS Lambda to invoke your handler. -
github.com/aws/aws-lambda-go/lambdacontext
: Helpers for accessing context information from the context object. -
github.com/aws/aws-lambda-go/events
: This library provides type definitions for common event source integrations. -
github.com/aws/aws-lambda-go/cmd/build-lambda-zip
: This tool can be used to create a .zip file archive on Windows.
For more information, see aws-lambda-go
Lambda provides the following sample applications for the Go runtime: