
Security News
CISA Rebuffs Funding Concerns as CVE Foundation Draws Criticism
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
serverless-go-build
Advanced tools
A Serverless v1.x plugin to making building Go easy!
Use your serverless.yml file as your build script, allowing specifying public functions or .go files as your entry points. Also can start other serverless plugins before running tests, and of course properly packages the built binary for upload (by default even individually packages each binary for increased performance!).
npm install --save serverless-go-build
serverless build
: Builds all Go binaries listed as function handlersserverless build --function getWidget
: Builds specific Go binariesserverless test
: Runs tests specified in serverless.yml
GO_TEST=serverless
and stage=testing
serverless deploy
will not run the builds - run serverless build
first.
serverless.yml
The below is a full serverless.yml example - however the only unique parts are:
custom.go-build
- Location of custom overrides (see below)package
- Optionally specify individually: true
for individual packagingfunctions.{yourFunction}.handler
- Specify your handler as .go file or module.PublicFunctionservice: myService
plugins:
- serverless-go-build
custom:
go-build:
# Example where we start "serverless-dynalite" prior to testing
testPlugins:
- dynalite:start
# Run tests defined in endpoints module/folder
tests:
- ./endpoints
provider:
name: aws
runtime: go1.x
stage: ${opt:stage, 'testing'}
package:
individually: true
# No need to include / exclude globally as each function
# specifies it's include / exclude
functions:
getWidget:
# In this case this file must be a main package with main()
handler: entrypoints/widget/get.go
name: myService-${self:provider.stage}-getWidget
events:
- http:
path: widget
method: get
postWidget:
# In this case this file must be a main package with main()
handler: entrypoints/widget/post.go
name: myService-${self:provider.stage}-postWidget
events:
- http:
path: widget
method: post
getPiece:
# Shows how to call into a modules public function
handler: piece.GetPiece
name: myService-${self:provider.stage}-postWidget
events:
- http:
path: widget
method: post
You can override any of these fields inside of custom.go-build
:
{
// Prefix used for building for AWS
awsbuildPrefix: 'GOOS=linux ',
// Build command - followed by bin dest and input path
buildCmd: `go build -ldflags="-s -w" -o %2 %1`,
// Test command - followed by value in tests array below
testCmd: `stage=testing GO_TEST=serverless go test %1`,
// Path to store build results
binPath: 'bin',
// Runtime to require
runtime: "go1.x",
// The path to aws-lambda-go/lambda - autogenerated include in main.go
// (needed when referring to module/PubFunction)
pathToAWSLambda: "github.com/aws/aws-lambda-go/lambda",
// Path to put generated main.go files (module/PubFunction)
generatedMainPath: "generatedEntrypoints",
// Location of go path - needed for (module/PubFunction)
// Must point fully to the /src segment of the path
// (By default pulls it from $GOPATH)
goPath: undefined,
// Pass this to minimize the package uploaded to just the binary
// for that endpoint
minimizePackage: true,
// Test plugins to start before running
testPlugins: [],
// Delay in milliseconds between starting plugins and starting tests
testStartDelay: 0,
// Array of tests to run
tests: [],
}
Will support in the future:
serverless test
command supporting running individual testpackage
for a function you must include the bin file
FAQs
Serverless plugin to build your go binaries
The npm package serverless-go-build receives a total of 50 weekly downloads. As such, serverless-go-build popularity was classified as not popular.
We found that serverless-go-build demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.