In this section, we will see how to build a deployment package for the function and how to deploy it to the AWS Lambda console.
Deployment package
Uploading a ZIP file
As mentioned in Chapter 1, Go Serverless, Go is a compiled language. Therefore, you must generate an executable binary using the following Shell script:
#!/bin/bash
echo "Build the binary"
GOOS=linux GOARCH=amd64 go build -o main main.go
echo "Create a ZIP file"
zip deployment.zip main
echo "Cleaning up"
rm main
The Lambda runtime environment is based on an Amazon Linux AMI; therefore, the handler should be compiled for Linux (note the use of the GOOS flag).
For Windows users, it's recommended you to use the build-lambda-zip tool...