{"id":20252597,"url":"https://github.com/streamdal/go-svc-template","last_synced_at":"2025-07-28T06:09:42.353Z","repository":{"id":248477253,"uuid":"813881739","full_name":"streamdal/go-svc-template","owner":"streamdal","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-11T23:44:23.000Z","size":4884,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-03T16:50:12.098Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/streamdal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-06-11T23:37:54.000Z","updated_at":"2024-06-11T23:44:27.000Z","dependencies_parsed_at":"2024-07-15T08:16:25.880Z","dependency_job_id":null,"html_url":"https://github.com/streamdal/go-svc-template","commit_stats":null,"previous_names":["streamdal/go-svc-template"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/streamdal/go-svc-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamdal%2Fgo-svc-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamdal%2Fgo-svc-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamdal%2Fgo-svc-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamdal%2Fgo-svc-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/streamdal","download_url":"https://codeload.github.com/streamdal/go-svc-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamdal%2Fgo-svc-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267470062,"owners_count":24092352,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-14T10:17:32.115Z","updated_at":"2025-07-28T06:09:42.324Z","avatar_url":"https://github.com/streamdal.png","language":"Go","readme":"go-svc-template\n===============\n\n⚡ Batteries-included Golang microservice template ⚡️\n\n_Last updated: 06/11/2024_\n\n**It includes:**\n\n1. `Makefile` that is used for run, test, build, deploy actions\n1. `Dockerfile` for building a Docker image (`alpine` with multi-stage build)\n1. `docker-compose.yml` for local dev\n1. Github workflows for [PR](.github/workflows/go-svc-template-pr.yml) and \n[release](.github/workflows/go-svc-template-release.yml) automation\n1. Sane code layout [1]\n1. Structured logging\n1. Good health-checking practices (uses async health-checking)\n1. Sample [kubernetes deploy configs](deploy.stage.yml)\n1. Configurable profiling support (pprof)\n1. Pre-instrumented with [New Relic APM](https://newrelic.com)\n1. DigitalOcean container registry support\n\n**It uses:**\n\n1. `Go 1.22`\n1. `julienschmidt/httprouter` for the HTTP router\n1. `uber/zap` for structured, light-weight logging\n1. `alecthomas/kong` for CLI args + ENV parsing\n1. `newrelic/go-agent` for APM (with logging)\n1. `streamdal/rabbit` for reliable RabbitMQ\n1. `onsi/ginkgo` and `onsi/gomega` for BDD-style testing\n\n\u003csub\u003e[1] `main.go` for entrypoint, `deps/deps.go` for dependency setup + simple\ndependency injection in tests, `backends` and `services` abstraction for business\nlogic.\u003c/sub\u003e\n\n## Makefile\nAll actions are performed via `make` - run `make help` to see list of available make args (targets).\n\nFor example:\n\n* To run the service, run `make run`\n* To build + push a docker img, run `make docker/build`\n* To deploy to staging, run `make k8s/deploy/stage` \u003c- make sure to switch Kube context to staging!!!\n* To deploy to production, run `make k8s/deploy/prod` \u003c- make sure to switch Kube context to production!!!\n\n## Secrets\n\nSecrets are stored in K8S using their native `Secret` resource.\n\nYou can create them via `kubectl`:\n\n```bash\nkubectl create secret generic my-secret --from-literal=secret-key=secret-value\n```\n\nYou can then edit it: `kubectl edit secret my-secret`\n\nNOTE: That the secret values are base64 encoded - when copy/pasting, make sure\nto decode them first:\n\n```bash\n❯ echo \"dG9vdAo=\" | base64 -D\ntoot\n```\n\nThe secrets can be referenced as follows in the deploy config:\n\n```yaml\nenv:\n  - name: MY_SECRET\n    valueFrom:\n      secretKeyRef:\n        name: my-secret\n        key: secret-key\n```\n\n## Logging\n\nThis service uses a custom logger that wraps `uber/zap` in order to provide a\nstructured logging interface. While NR is able to collect logs written via `uber/zap`,\nit does not include any \"initial fields\" set on the logger.\n\nThis makes it very difficult to create temporary loggers with base values that\nare re-used throughout a method. For example: In method `A` that is 100 lines\nlong, we may want to create a logger with a base field \"method\" set to \"A\".\n\nThat would allow us to use the same logger throughout the method and not have\nto always include \"method=A\" attributes in each log message - the field will be\nincluded automatically.\n\nThe custom log wrapper provides this functionality.\n\n## PR and Release\n\nPR and release automation is done via GitHub Actions.\n\nWhen a PR is opened, a [PR workflow](.github/workflows/go-svc-template-pr.yml)\nis triggered.\n\nWhen a PR is merged, a [Release workflow](.github/workflows/go-svc-template-release.yml)\nis triggered. This workflow will build a docker image and push it to the\nDigitalOcean registry.\n\n## Deployment\n\nDeployment is _manual_. This is done for one primary reason:\n\n**A deployment is a critical operation that should be handled with care.**\n\n_Or in other words, we do not throw deployments over the wall. Just because we\ncan automate them, does not mean we should or will._\n\nDeployments are performed via `make k8s/deploy/stage` and `make k8s/deploy/prod`.\n\nDeployments are just `kubectl apply -f deploy.stage.yaml` under the hood. The image\nthe deployment will use is the _CURRENT_ short git sha in the repo!\n\n---\n\n## Template Usage\n\n1. Click \"Use this template\" in Github to create a new repo\n1. Clone newly created repo\n1. Find \u0026 replace:\n   1. `go-svc-template` -\u003e lower case, dash separated service name\n   2. `GO_SVC_TEMPLATE` -\u003e upper case, underscore separated service name (for ENV vars)\n   3. `your_org` -\u003e your Github org name\n    ```bash\n    find . -maxdepth 3 -type f -exec sed -i \"\" 's/go-svc-template/service-name/g' {} \\;\n    find . -maxdepth 3 -type f -exec sed -i \"\" 's/GO_SVC_TEMPLATE/SERVICE_NAME/g' {} \\;\n    find . -maxdepth 3 -type f -exec sed -i \"\" 's/your_org/your-org-name/g' {} \\;\n    mv .github.rename .github\n   ```\n\n## Vendor\n\nThis template vendors packages by default to ensure reproducible builds + allow\nlocal dev without an internet connection. Vendor can introduce its own headaches\nthough - if you want to remove it, remove `-mod=vendor` in the [`Makefile`](Makefile).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamdal%2Fgo-svc-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstreamdal%2Fgo-svc-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamdal%2Fgo-svc-template/lists"}