Awesome
<!-- editorconfig-checker-disable --> <!-- editorconfig-checker-enable -->Template: Go application
Just how I set up my go apps, which I most certainly do not claim to be best practice or anything. Comments welcome!
Features
- spf13/cobra for implementing the command-line interface
- Acceptance tests with Cucumber
To Do
Things I want to include, but haven't gotten around to yet:
- Go: set up logging
- Go: reading config files with spf13/viper
- CI: run tests before releasing
- CI:
test/Dockerfile
should use versions from mise config
Developer Setup
Testing
- We include a test workflow that runs unit and acceptance tests with coverage.
- Run unit tests through
go test
, as per usual. - Run acceptance tests through test/Dockerfile; a run configuration for IDEA/GoLand is included.
- Run acceptance tests with coverage like so:
<!-- TODO: Is there a nicer way? -->docker rm template-goapp-test rm -f test/coverage/* docker build -f test/Dockerfile -t template-goapp-test . \ && docker run -it --name template-goapp-test template-goapp-test \ && docker cp template-goapp-test:/home/test/app/coverage test/ go tool covdata percent -i=test/coverage
Tooling
- jdx/mise for managing tools and environment variables
- aquaproj/aqua for managing tool dependencies
- .editorconfig for consistent formatting
- golangci/golangci-lint for maintaining orderly Go code
- rubocop/rubocop for maintaining orderly Ruby code
- cocogitto/cocogitto for maintaining an orderly Git history
- evilmartians/lefthook for pre-commit hooks
- miniscruff/changie for creating changelogs
- goreleaser/goreleaser for release assembly
- GitHub Actions for testing and releasing
- Renovate for keeping dependencies up to date
- GoLand for the typing
Limitations
- Trigger Release
creates a release draft without a tag;
publishing the draft will create the tag on
main
-- don't wait around!
Instantiating the template
- Install aqua and mise
- "Use this template" from GitHub web UI
- Change some settings on GitHub:
- Add label
no changelog
- Activate RenovateBot for the new repository (Docs)
- Add label
- Clone your new repository
- Run
aqua install
(or install the tools listed above in whichever way pleases you) - Run
mise install
(or install matching Go and Ruby in whichever you pleases you) - Run
lefthook install
(optional) rm .changes/unreleased/* .changes/v*.md && changie merge
- Replace all occurrences of
[reitzig/]template-goapp
with[your-account/]your-app
- Rewrite README, replace LICENSE
- If you want to keep the badge linking to this template <3, you may also want to replace the linked revision to the one you used.