Deployment package
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.
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).
Note
For Windows users, it's recommended you to use the build-lambda-zip
tool to create a working ZIP file for Lambda.
Execute the Shell script as follows:

Now our ZIP file has been generated; you can now go back to the Lambda console and upload the ZIP file, making sure to update the Handler
to main
and save the results:

Note
The Handler
configuration property must match the...