npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

serverless-go-build

v0.0.6

Published

Serverless plugin to build your go binaries

Readme

Serverless Go Builds

Serverless License NPM

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!).

Features

  • Runs build for all go files listed as handlers (no separate build script!)
  • Specify go files or Public Functions directly (or continue to use path to binary)
    • Allows specifying packageName.FunctionName as function handler
  • Runs go tests
  • Can start serverless plugins before tests
    • eg: S3 or Dynalite test server - these can initialize resources based on yaml file
  • Individually packages each function for minimum lambda code size
    • Instead of sending one zip up with all binaries
  • Heavily customizable!
    • Doesn't even have to build Go!

Installation

npm install --save serverless-go-build

Usage

  • serverless build : Builds all Go binaries listed as function handlers
  • serverless build --function getWidget : Builds specific Go binaries
  • serverless test : Runs tests specified in serverless.yml
    • Passes in Environment variables GO_TEST=serverless and stage=testing

serverless deploy will not run the builds - run serverless build first.

Example 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 packaging
  • functions.{yourFunction}.handler - Specify your handler as .go file or module.PublicFunction
service: 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

Customization

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: [],
}

Coming Soon

Will support in the future:

  • serverless test command supporting running individual test
  • Building locally vs for AWS

Important Notes

  • If you override package for a function you must include the bin file
    • We do not override package or add to it if you specify it explicitly