{"id":17100253,"url":"https://github.com/mthenw/serverless-go-plugin","last_synced_at":"2025-05-16T11:06:38.503Z","repository":{"id":42991804,"uuid":"198502674","full_name":"mthenw/serverless-go-plugin","owner":"mthenw","description":"⚡️ Serverless Framework plugin that compiles Go functions on the fly. Sponsored by https://cloudash.dev","archived":false,"fork":false,"pushed_at":"2025-02-19T12:20:18.000Z","size":328,"stargazers_count":105,"open_issues_count":14,"forks_count":17,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-09T10:01:42.223Z","etag":null,"topics":["aws-lambda","go","golang","serverless","serverless-framework"],"latest_commit_sha":null,"homepage":"https://cloudash.dev","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mthenw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-23T20:20:58.000Z","updated_at":"2024-11-17T22:28:53.000Z","dependencies_parsed_at":"2024-04-04T11:28:56.580Z","dependency_job_id":"820f4f5b-7186-42f1-bdc8-d195dad449b8","html_url":"https://github.com/mthenw/serverless-go-plugin","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mthenw%2Fserverless-go-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mthenw%2Fserverless-go-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mthenw%2Fserverless-go-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mthenw%2Fserverless-go-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mthenw","download_url":"https://codeload.github.com/mthenw/serverless-go-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253487377,"owners_count":21916147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","go","golang","serverless","serverless-framework"],"created_at":"2024-10-14T15:12:52.846Z","updated_at":"2025-05-16T11:06:35.369Z","avatar_url":"https://github.com/mthenw.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚡️Serverless Framework Go Plugin\n\n[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)\n[![npm](https://img.shields.io/npm/v/serverless-go-plugin)](https://www.npmjs.com/package/serverless-go-plugin)\n[![codecov](https://codecov.io/gh/mthenw/serverless-go-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/mthenw/serverless-go-plugin)\n\n`serverless-go-plugin` is a Serverless Framework plugin that compiles Go functions on the fly. You don't need to do it manually before `serverless deploy`. Once the plugin is installed it will happen automatically. *The plugin works with Serverless Framework version 1.52 and above.*\n\n### [dev.to: A better way of deploying Go services with Serverless Framework](https://dev.to/mthenw/a-better-way-of-deploying-go-services-with-serverless-framework-41c4)\n\n![output](https://user-images.githubusercontent.com/455261/73918022-fb952e00-48c0-11ea-9120-a7f34ad1ae55.gif)\n\n## Features\n\n- Concurrent compilation happens across all CPU cores.\n- Support for both `serverless deploy` and `serverless deploy function` commands.\n- Support for `serverless invoke local` command.\n- Additional command `serverless go build`.\n\n## Install\n\n\n1. Install the plugin\n\n    ```\n    npm i --save-dev serverless-go-plugin\n    ```\n\n1. Add it to your `serverless.yaml`\n\n    ```\n    plugins:\n      - serverless-go-plugin\n    ```\n\n1. Replace every Go function's `handler` with `*.go` file path or a package path. E.g.\n\n    ```\n    functions:\n      example:\n        runtime: go1.x\n        handler: functions/example/main.go # or just functions/example\n    ```\n\n## Configuration\n\nDefault values:\n\n```\ncustom:\n  go:\n    baseDir: . # folder where go.mod file lives, if set `handler` property should be set relatively to that folder\n    binDir: .bin # target folder for binary files\n    cgo: 0 # CGO_ENABLED flag\n    cmd: 'GOOS=linux go build -ldflags=\"-s -w\"' # compile command\n    monorepo: false # if enabled, builds function every directory (useful for monorepo where go.mod is managed by each function\n    supportedRuntimes: [\"go1.x\"] # the plugin compiles a function only if runtime is declared here (either on function or provider level) \n    buildProvidedRuntimeAsBootstrap: false # if enabled, builds and archive function with only single \"bootstrap\" binary (useful for runtimes like provided.al2)\n```\n\n## How does it work?\n\nThe plugin compiles every Go function defined in `serverless.yaml` into `.bin` directory. After that it internally changes `handler` so that the Serverless Framework will deploy the compiled file not the source file.\n\nFor every matched function it also overrides `package` parameter to\n\n```\nindividually: true\nexclude:\n  - `./**`\ninclude:\n  - `\u003cpath to the compiled file and any files that you defined to be included\u003e`\n```\n\n## How to run Golang Lambda on ARM?\n\n1. Add `provided.al2` to `supportedRuntimes` and enable `buildProvidedRuntimeAsBootstrap` in plugin config\n2. Append `GOARCH=arm64` to your compile command (`cmd` line)\n3. Change architecture and runtime in global config:\n```yaml\nprovider:\n    architecture: arm64\n    runtime: provided.al2\n```   \n\n**Warning!** First deploy may result in small downtime (~few seconds) of lambda, use some deployment strategy like canary for safer rollout.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmthenw%2Fserverless-go-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmthenw%2Fserverless-go-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmthenw%2Fserverless-go-plugin/lists"}