Follow the steps in this section to create your first Lambda function in Go from scratch:
- To write a Lambda function, we need to install some dependencies. Hence, open a new terminal session, and install the Go Lambda package using the following command:
go get github.com/aws/aws-lambda-go/lambda
- Next, open your favorite Go IDE or editor; in my case, I will work with VS Code. Create a new project directory in your GOPATH and then paste the following content into a main.go file:
package main
import "github.com/aws/aws-lambda-go/lambda"
func handler() (string, error){
return "Welcome to Serverless world", nil
}
func main() {
lambda.Start(handler)
}
The previous code uses the lambda.Start() method to register an entry-point handler that contains the code that will be executed when a Lambda function is invoked. Each language supported...