This repo provides a base template for a new go project.
It is highly opinionated and may not work for your usecase. I write a lot of cobra apps and employ magefiles in place of makefiles, so this template will be very focused around supporting projects of that nature.
-
# Linux sudo apt-get update sudo apt-get install -y build-essential procps curl file git /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" # macOS /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) source "${GVM_BIN}"
-
source .gvm
-
brew install pre-commit
-
go install github.com/magefile/mage@latest
-
(Optional) If you installed gvm, create golang pkgset specifically for this project:
gvm pkgset create "${PROJECT}" gvm pkgset use "${PROJECT}"
-
Install pre-commit hooks and dependencies:
mage installPreCommitHooks
-
Update and run pre-commit hooks locally:
mage runPreCommit
To get started, you will need to:
- Create a new repo with this template
- Replace all instances of PROJECT_NAME, BIN_NAME, l50, and goproject found throughout the codebase
- Customize as needed