Registry / aws / serverless-go-build

serverless-go-build

JSON →
library0.0.6jsnpmunverified

A Serverless v1.x plugin to build Go binaries for AWS Lambda functions. Version 0.0.6 is the latest release as of the provided data. The plugin integrates with the Serverless Framework (v1.x) to automate building of Go code, allowing developers to specify .go files or module.Function as handlers in serverless.yml. Key differentiators: automatically builds all Go functions listed as handlers, supports individual packaging for reduced Lambda code size, runs Go tests with optional serverless plugin hooks, and is highly customizable via serverless.yml. It is less actively maintained compared to alternatives like serverless-go-plugin.

npm install serverless-go-build
INSTALL
IMPORT
SIG · SERVERLESS-GO-BUIL
S
serverless-go-build
awsjavascriptv0.0.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

serverless-go-build
plugins: - serverless-go-build
plugins: - serverless-go-build@0.0.6
Plugin is added to serverless.yml plugins list; no JavaScript import needed.
custom.go-build
custom: go-build: binPath: 'bin'
custom: go-build: binPath: './bin'
Configuration is placed under custom.go-build in serverless.yml; relative paths are relative to project root without './'.
handler
functions: myFunc: handler: main.go
functions: myFunc: handler: ./main.go
Handler value can be a .go file path (relative to project) or a module.Function name; no leading './'.

Install plugin, configure serverless.yml with Go handler, create main.go Lambda function, build and deploy.

npm install --save serverless-go-build # serverless.yml service: myService plugins: - serverless-go-build custom: go-build: binPath: bin provider: name: aws runtime: go1.x package: individually: true functions: hello: handler: main.go name: myService-dev-hello events: - http: path: hello method: get # main.go (in root) package main import "github.com/aws/aws-lambda-go/lambda" func main() { lambda.Start(HandleRequest) } func HandleRequest() (string, error) { return "Hello from Go!", nil } # build and deploy serverless build serverless deploy
serverless --version
Debug
Known issues
breakingPlugin only supports Serverless v1.x; incompatible with v2/v3.
fix
Use alternative plugin or stay on Serverless v1.x.
affects: >=2.0.0
gotchaBuild must be run explicitly with `serverless build` before `serverless deploy`; deploy does not auto-build.
fix
Run `serverless build` prior to `serverless deploy` or configure a deploy hook.
affects: all
deprecatedPlugin uses deprecated GOOS prefix `GOOS=linux ` which may not work on all shells.
fix
Override awsbuildPrefix with a safer value like `GOOS=linux` (without trailing space) or set it to empty string.
affects: all
gotchaWhen specifying a module function handler (e.g., piece.GetPiece), the plugin generates a main.go file; ensure the package is importable and the generated path is writable.
fix
Check generatedEntrypoints directory and ensure module path is correct in custom.go-build.pathToAWSLambda.
affects: all
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, open 'generatedEntrypoints/main.go'
The plugin tries to generate a main.go for module function handlers but the directory does not exist or is not writable.
fix
Manually create the `generatedEntrypoints` directory in your project root, or change the path via `custom.go-build.generatedMainPath`.
Error: No handler given. Please define a valid handler.
The function handler in serverless.yml does not match an existing .go file or a valid module.Function.
fix
Ensure the handler value points to an existing .go file (e.g., `main.go`) or a module function (e.g., `packageName.FunctionName`) with a generated main.go.
Error: go build command failed with exit code 1
The Go source code has compilation errors or the build command is misconfigured.
fix
Check your Go files for syntax errors and verify `custom.go-build.buildCmd` and `custom.go-build.awsbuildPrefix` are correct for your environment.
Upgrade
Version history
0.0.6latest on npm
Audit
Dependencies
serverlessrequiredPeer dependency; plugin requires Serverless v1.x framework.
Agent activity
10 hits · last 30 days
node
8
Amazon
1
Resources
serverless-go-build — npm install serverless-go-build · libregistry