Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/lambda/handler-runner/HandlerRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
supportedGo,
supportedJava,
supportedNodejs,
supportedProvided,
supportedPython,
supportedRuby,
unsupportedDockerRuntimes,
Expand Down Expand Up @@ -66,7 +67,10 @@ export default class HandlerRunner {
return new WorkerThreadRunner(this.#funOptions, this.#env)
}

if (supportedGo.has(runtime)) {
if (
supportedGo.has(runtime) ||
(supportedProvided.has(runtime) && handler.endsWith('.go'))
) {
const { default: GoRunner } = await import('./go-runner/index.js')

return new GoRunner(this.#funOptions, this.#env)
Expand Down
1 change: 1 addition & 0 deletions tests/runtimes/go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/
1 change: 1 addition & 0 deletions tests/runtimes/go/provided.al2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin
5 changes: 5 additions & 0 deletions tests/runtimes/go/provided.al2/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module serverless-offline-go-provided.al2-test

go 1.13

require github.com/aws/aws-lambda-go v1.28.0
22 changes: 22 additions & 0 deletions tests/runtimes/go/provided.al2/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/aws/aws-lambda-go v1.28.0 h1:fZiik1PZqW2IyAN4rj+Y0UBaO1IDFlsNo9Zz/XnArK4=
github.com/aws/aws-lambda-go v1.28.0/go.mod h1:jJmlefzPfGnckuHdXX7/80O3BvUUi12XOkbv4w9SGLU=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
19 changes: 19 additions & 0 deletions tests/runtimes/go/provided.al2/hello/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"context"

"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)

func Handler(ctx context.Context, req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
return events.APIGatewayProxyResponse{
Body: "{\"message\": \"Hello Go on provided.al2!\"}",
StatusCode: 200,
}, nil
}

func main() {
lambda.Start(Handler)
}
38 changes: 38 additions & 0 deletions tests/runtimes/go/provided.al2/provided.al2.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import assert from 'node:assert'
import { env } from 'node:process'
import { join } from 'desm'
import { setup, teardown } from '../../../_testHelpers/index.js'
import { BASE_URL } from '../../../config.js'

describe('Go via provided.al2 with GoRunner', function desc() {
beforeEach(() =>
setup({
servicePath: join(import.meta.url),
}),
)

afterEach(() => teardown())

//
;[
{
description: 'should work with provided.al2',
expected: {
message: 'Hello Go on provided.al2!',
},
path: '/dev/hello',
},
].forEach(({ description, expected, path }) => {
it(description, async function it() {
if (!env.GO1X_DETECTED) {
this.skip()
}

const url = new URL(path, BASE_URL)
const response = await fetch(url)
const json = await response.json()

assert.deepEqual(json, expected)
})
})
})
29 changes: 29 additions & 0 deletions tests/runtimes/go/provided.al2/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
service: docker-go-provided-al2-tests

configValidationMode: error
deprecationNotificationMode: error

plugins:
- ../../../../src/index.js

provider:
architecture: arm64
deploymentMethod: direct
memorySize: 1024
name: aws
region: us-east-1
runtime: provided.al2
stage: dev
versionFunctions: false

custom:
serverless-offline:
noTimeout: true

functions:
hello:
events:
- http:
method: get
path: hello
handler: hello/main.go