This is an opinionated go project template to use as a starting point for new projects.
- Builds with GoReleaser
- Automated with GitHub Actions
- Signed with Cosign (providing you generate a private key)
- Linting with golangci-lint
- Automated with GitHub Actions
- Builds with Docker
- While designed to use goreleaser, you can still just run
docker build
- While designed to use goreleaser, you can still just run
- Opinionated Layout
- Never use
internal/
folder - Everything is under
pkg/
folder
- Never use
- Automatic Dependency Management with Renovate
- Automatic Releases with Release Drafter
- Documentation with Material for MkDocs
- API Server Example
- Uses Gorilla Mux (yes it's been archived, still the best option)
- Stubbed out Go Tests
- They are not comprehensive
- Uses
init
functions for registering commands globally.- This allows for multiple
main
package files to be written and include different commands. - Allows the command code to remain isolated from each other and a simple import to include the command.
- This allows for multiple
The following will build binaries in snapshot order.
goreleaser --clean --snapshot
- Rename Repository
- Generate Cosign Keys
- Update
.goreleaser.yml
, search/replace go-project-template with new project name, adjust GitHub owner - Update
main.go
, - Update
go.mod
, rename go project (using IDE is best so renames happen across all files)
- Create a password
- Recommend exporting in environment as
COSIGN_PASSWORD
using something like direnv
- Recommend exporting in environment as
- Generate cosign keys
cosign generate-key-pair
- Create GitHub Action Secrets
COSIGN_KEY
-> populate with cosign.key valueCOSIGN_PASSWORD
-> populate with password from step 1
In order for Release Drafter and GoReleaser to work properly you have to create a PAT to run Release Drafter so it's actions against the repository can trigger other workflows. Unfortunately there is no way to trigger a workflow from a workflow if both are run by the automatically generated GitHub Actions secret.
- Create PAT that has write contents permissions to the repository
- Create GitHub Action Secret
RELEASE_DRAFTER_SECRET
-> populated with PAT from step 1
- Done
The project is built to have the documentation right alongside the code in the docs/
directory leveraging Mkdocs Material.
In the root of the project exists mkdocs.yml which drives the configuration for the documentation.
This README.md is currently copied to docs/index.md
and the documentation is automatically published to the GitHub
pages location for this repository using a GitHub Action workflow. It does not use the gh-pages
branch.
make docs-serve
OR (if you have docker)
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material