/go-service-boilerplate

Golang App Boilerplate is a bulletproof Golang App template with batteries included ๐Ÿ”‹

Primary LanguageShellMIT LicenseMIT

Logo

GoService Boilerplate โšก๏ธ

A simple, opinionated and battle-tested boilerplate for services/microservices/fullstack Go apps.


GitHub release (latest by date) Software License Powered By: GoReleaser Docker Build Go Build Go linter Go unit tests Lint Docker Yamllint GitHub Actions


Getting Started ๐Ÿšฆ

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 simple Ctrl+Shift+R and replace all the occurrences of go-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 (or make air-setup).
  • Update the LICENSE.md file with your own license.
  • Verify that everything is working as expected by running task go-ci (or make 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.


๐Ÿ“š Documentation

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 the docs folder. For more details about the document templates, see this.


Features ๐Ÿงฉ

  • 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 ๐Ÿงฉ

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 ๐Ÿšง)

Tooling ๐Ÿง‘โ€๐Ÿ”ง

This template is equipped with an array of tools to maintain a high standard of code quality and accelerate the development process:

NOTE: For pre-commit, ensure you're running task pre-commmit-init to add the pre-configured hooks into your git 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.).


Roadmap ๐Ÿ—“๏ธ

  • 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.

Contributing

Please read our contributing guide. All issues, pull requests and GitHub stars are welcome! Happy coding! ๐Ÿ’ป

Community

Find me in: