{"id":18783,"library":"serverless-go-build","title":"serverless-go-build","description":"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.","status":"active","version":"0.0.6","language":"javascript","source_language":"en","source_url":"https://github.com/sean9keenan/serverless-go-build","tags":["javascript","serverless","1.0","go","golang","build","plugin"],"install":[{"cmd":"npm install serverless-go-build","lang":"bash","label":"npm"},{"cmd":"yarn add serverless-go-build","lang":"bash","label":"yarn"},{"cmd":"pnpm add serverless-go-build","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin requires Serverless v1.x framework.","package":"serverless","optional":false}],"imports":[{"note":"Plugin is added to serverless.yml plugins list; no JavaScript import needed.","wrong":"plugins:\n  - serverless-go-build@0.0.6","symbol":"serverless-go-build","correct":"plugins:\n  - serverless-go-build"},{"note":"Configuration is placed under custom.go-build in serverless.yml; relative paths are relative to project root without './'.","wrong":"custom:\n  go-build:\n    binPath: './bin'","symbol":"custom.go-build","correct":"custom:\n  go-build:\n    binPath: 'bin'"},{"note":"Handler value can be a .go file path (relative to project) or a module.Function name; no leading './'.","wrong":"functions:\n  myFunc:\n    handler: ./main.go","symbol":"handler","correct":"functions:\n  myFunc:\n    handler: main.go"}],"quickstart":{"code":"npm install --save serverless-go-build\n\n# serverless.yml\nservice: myService\nplugins:\n  - serverless-go-build\ncustom:\n  go-build:\n    binPath: bin\nprovider:\n  name: aws\n  runtime: go1.x\npackage:\n  individually: true\nfunctions:\n  hello:\n    handler: main.go\n    name: myService-dev-hello\n    events:\n      - http:\n          path: hello\n          method: get\n\n# main.go (in root)\npackage main\n\nimport \"github.com/aws/aws-lambda-go/lambda\"\n\nfunc main() {\n  lambda.Start(HandleRequest)\n}\n\nfunc HandleRequest() (string, error) {\n  return \"Hello from Go!\", nil\n}\n\n# build and deploy\nserverless build\nserverless deploy","lang":"javascript","description":"Install plugin, configure serverless.yml with Go handler, create main.go Lambda function, build and deploy."},"warnings":[{"fix":"Use alternative plugin or stay on Serverless v1.x.","message":"Plugin only supports Serverless v1.x; incompatible with v2/v3.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Run `serverless build` prior to `serverless deploy` or configure a deploy hook.","message":"Build must be run explicitly with `serverless build` before `serverless deploy`; deploy does not auto-build.","severity":"gotcha","affected_versions":"all"},{"fix":"Override awsbuildPrefix with a safer value like `GOOS=linux` (without trailing space) or set it to empty string.","message":"Plugin uses deprecated GOOS prefix `GOOS=linux ` which may not work on all shells.","severity":"deprecated","affected_versions":"all"},{"fix":"Check generatedEntrypoints directory and ensure module path is correct in custom.go-build.pathToAWSLambda.","message":"When 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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Manually create the `generatedEntrypoints` directory in your project root, or change the path via `custom.go-build.generatedMainPath`.","cause":"The plugin tries to generate a main.go for module function handlers but the directory does not exist or is not writable.","error":"Error: ENOENT: no such file or directory, open 'generatedEntrypoints/main.go'"},{"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.","cause":"The function handler in serverless.yml does not match an existing .go file or a valid module.Function.","error":"Error: No handler given. Please define a valid handler."},{"fix":"Check your Go files for syntax errors and verify `custom.go-build.buildCmd` and `custom.go-build.awsbuildPrefix` are correct for your environment.","cause":"The Go source code has compilation errors or the build command is misconfigured.","error":"Error: go build command failed with exit code 1"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}