Go Repository Template
This is a GitHub repository template for Go. It has been created for ease-of-use for anyone who wants to:
- quickly get into Go without losing too much time on environment setup,
- create a new repoisitory with basic Continous Integration.
- continous integration via GitHub Actions,
- build automation via Make,
- dependency management using Go Modules,
- code formatting using gofumpt,
- linting with golangci-lint,
- unit testing with testify, race detector, code covarage HTML report and Codecov report,
- releasing using GoReleaser,
- dependencies scanning and updating thanks to Dependabot,
- security code analysis using CodeQL Action,
- Visual Studio Code configuration with Go and Remote Container support.
Star this repository if you find it valuable and worth maintaining.
Watch this repository to get notified about new releases, issues, etc.
- Sign up on Codecov and configure Codecov GitHub Application for all repositories.
- Click the
Use this templatebutton (alt. clone or download this repository).
- Replace all occurences of
your_org/repo_namein all files.
- Rename folder
cmd/app_nameand update .goreleaser.yml accordingly.
- Update LICENSE and README.md.
maketo get help for make targets.
- Visual Studio Code:
Run Build Task... (CTRL+ALT+B)to execute a fast build.
The release workflow is triggered each time a tag with
v prefix is pushed.
- devcontainer.json - Visual Studio Code Remote Container configuration,
- .github/workflows - GitHub Actions workflows,
- .github/dependabot.yml - Dependabot configuration,
- .vscode - Visual Studio Code configuration files,
- .golangci.yml - golangci-lint configuration,
- .goreleaser.yml - GoReleaser configuration,
- Makefile - Make targets used for development, CI build and .vscode/tasks.json,
- go.mod - Go module definition,
- tools.go - build tools.
Why Visual Studio Code editor configuration
Developers that use Visual Studio Code can take advantage of the editor configuration. While others do not have to care about it. Setting configs for each repo is unnecessary time consuming. VS Code is the most popular Go editor (survey) and it is officially supported by the Go team.
Why GitHub Actions, not any other CI server
GitHub Actions is out-of-the-box if you are already using GitHub. Here you can learn how to use it for Go.
However, changing to any other CI server should be very simple, because this repository has build logic and tooling installation in Makefile.
You can also use the
docker make target to run the build using a docker container.
How can I build on Windows
Install tdm-gcc and copy
How can I create an application installation script
- Install GoDownloader.
godownloader --repo=your_org/repo_name > ./install.sh
install.shto your repository.
- Add installation instructions to your
curl -sSfL https://raw.githubusercontent.com/your_org/repo_name/master/install.sh | sh -s -- -b /usr/local/bin
How can I create a Docker image, deb/rpm/snap package, Homebrew Tap, Scoop App Manifest etc.
How can I create a library instead of an application
You can change the .goreleaser.yml to contain:
build: skip: true release: github: prerelease: auto
Alternatively, you can completly remove the usage of GoReleaser if you prefer handcrafted release notes.
Why the code coverage results are not accurate
How to automate generating git tags for next release version
Auto-tagging can be done in many ways e.g. by using GitHub Actions like:
However, creating a release tag manually is often the optimal approach. Take notice that this template executes a release workflow each time a git tag with
v prefix is pushed.
Simply create an issue or a pull request.