AWS Lambda Go
This example shows how to use the go runtime in your Lambda
functions.
Our Go function is in the src directory and we point to it in our function.
new sst.aws.Function("MyFunction", { url: true, runtime: "go", link: [bucket], handler: "./src",});We are also linking it to an S3 bucket. We can reference the bucket in our function.
func handler() (string, error) { bucket, err := resource.Get("MyBucket", "name") if err != nil { return "", err } return bucket.(string), nil}The resource.Get function is from the SST Go SDK.
import ( "github.com/sst/sst/v3/sdk/golang/resource")The sst dev CLI also supports running your Go function Live.
const bucket = new sst.aws.Bucket("MyBucket");
new sst.aws.Function("MyFunction", { url: true, runtime: "go", link: [bucket], handler: "./src",});View the full example.