directory layout
.
├── event.json
├── main.go
└── template.ymlmain.go
package main
import (
"github.com/aws/aws-lambda-go/lambda"
)
func hello() (string, error) {
return "Hello ƛ!", nil
}
func main() {
// Make the handler available for Remote Procedure Call by AWS Lambda
lambda.Start(hello)
}template.yml
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: An example lambda which is written by Golang
Resources:
ExampleAPI:
Type: AWS::Serverless::Function
Properties:
Runtime: go1.x
Handler: mainRun
$ GOOS=linux GOARCH=amd64 go build -o main main.go
$ echo '{}' > event.json
$ sam local invoke -e event.js