A simple, opinionated and battle-tested boilerplate for services/microservices/fullstack Go apps.
Use this repository as a GitHub Template to create your own service/app:
- Clone this repository and start adding your command and flag definitions. Utilize pre-installed AWS adapters and included or remove the included utilities to kickstart your development.
- This template is called
go-service-boilerplate
. You can rename it by changing the name using your favourite tool, or just using our IDE with a simpleCtrl+Shift+R
and replace all the occurrences ofgo-service-boilerplate
with your new name (or including the org/go-service-boilerplate
) if applicable. - Configure PreCommit hooks by running
task pre-commit-init
. This will install the pre-commit hooks in your local repository. - Configure Air for live reloading by running
task air-setup
(ormake air-setup
). - Update the
LICENSE.md
file with your own license. - Verify that everything is working as expected by running
task go-ci
(ormake go-ci
).
NOTE: This template includes a MakeFile and a TaskFile with the necessary (best practices) configuration to build and lint your App. Both tools include the same capability, so you can choose the one you prefer.
Documenting your App is relevant. This repository includes a docs folder with a template for the documentation of your App. You can use it as a starting point for your own documentation. It includes:
- ๐
README.md
with a standard structure for a App repository. - ๐
RELEASE.md
file with the release instructions for your App. - ๐
CONTRIBUTING.md
file with the instructions for contributing to your App. - ๐
CODE_OF_CONDUCT.md
file with the code of conduct for your App. - ๐
LICENSE.md
file with the license for your App.
tree -L 3 docs/
docs/
โโโ about_docs.md
โโโ templates
โโโ CODE_OF_CONDUCT.md
โโโ CONTRIBUTING.md
โโโ RELEASE.md
โโโ LICENSE
โโโ README.md
NOTE: It's recommended to move these files accordingly, nevertheless it's strongly encouraged to keep a concise documentation structure, keeping the
README.md
simple, concise, and store the more detailed documentation in thedocs
folder. For more details about the document templates, see this.
- Auto-scan host environment variables (useful for
AWS
,Terraform
and other common use cases). - Import env vars from dotfiles (
.env
) ๐ - Leverages built-in AWS adapters (Golang SDK v2)
- Ready-to-use utilities for common tasks ๐งฐ. See the pkg folder for more details.
- Simple API for adding a Fiber server ๐ (Web, Rest or a custom one).
- Built-in Docker support ๐ณ. Check the
./container
folder for more details. - Out-of-the-box GitHub Actions workflows for CI/CD ๐
- Built-in PreCommit hooks for linting and formatting ๐งน
- Server modes that are ready for either dev or prod environments ๐
- Set of middlewares for Fiber ๐งฉ (CORS, compression, etc.)
- The latest sLog for logging ๐
Adapters are known also as interfaces/drivers
. They can plug into the App
and provide additional functionality. This template comes with the following:
- AWS - AWS SDK v2 for Golang.
- SuPaBase - Simple client for Supabase.
- GitHub - Simple client for GitHub. (Coming soon ๐ง)
- OpenAI - Simple client for OpenAI. (Coming soon ๐ง)
This template is equipped with an array of tools to maintain a high standard of code quality and accelerate the development process:
- Precommit framework for managing and maintaining multi-language pre-commit hooks
- Taskfile is a simpler way to automate tasks
- Makefile for managing build workflow
- GolangCI-linter for consolidated linting to improve code quality
- GoReleaser for easy binary release management
- Docker for containerization
- ShellCheck for shell script linting
- Release please for automated releases
NOTE: For pre-commit, ensure you're running
task pre-commmit-init
to add the pre-configured hooks into yourgit
hooks. This will ensure that the code is linted and formatted before committing it. Also, there are other linters included (yaml, docker, shell, md, etc.).
- Add a built-in GitHubGitHub adapter for generating App documentation and/or other purposes.
- Add an OpenAI adapter for generating App documentation and/or other purposes.
Please read our contributing guide. All issues, pull requests and GitHub stars are welcome! Happy coding! ๐ป
Find me in: