An advanced starter Golang Repository Template

Golang Starter Template

This is a

GitHub repository template for Golang.

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 repository with essential Continous Integration.

It includes:

  • continuous-integration via GitHub Actions,
  • dependency management using Golang Modules,
  • code formatting using gofumpt,
  • linting with golangci-lint,
  • build automation via Make,
  • unit testing with testify, race detector, code coverage 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.

Golang Project Template Usage

  1. Sign up on Codecov and configure Codecov GitHub Application for all repositories.
  2. Click the Use this template button (alt. clone or download this repository).
  3. Replace all occurrences of golang-templates/seed with your_org/repo_name in all files.
  4. Replace all occurrences of seed to repo_name in Dockerfile.
  5. Update the following files:

Setup the Golang Development Environment

Below you can find sample instructions on how to set up the development environment. Of course, you can use other tools like GoLand, Vim, Emacs. However, take notice that the Go team officially supports the Visual Studio Go extension.

Local Machine

Follow these steps if you are OK installing and using Go on your machine.

  1. Install Go.
  2. Install Visual Studio Code.
  3. Install Go extension.
  4. Clone and open this repository.
  5. F1 -> Go: Install/Update Tools -> (select all) -> OK.

Golang Development Container

Follow these steps if you do not want to install Golang on your machine and you prefer to use a Development Container instead.