/goproject

Primary LanguageGoMIT LicenseMIT

Go Project Template

Go Report Card License Tests 🚨 CodeQL Analysis 🚨 Semgrep Analysis Coverage Status Renovate

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.

Dependencies

  • Install homebrew:

    # 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)"
  • Install gvm:

    bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
    source "${GVM_BIN}"
  • Install golang:

    source .gvm
  • Install pre-commit:

    brew install pre-commit
  • Install Mage:

    go install github.com/magefile/mage@latest

Developer Environment Setup

  1. Fork this project

  2. (Optional) If you installed gvm, create golang pkgset specifically for this project:

    gvm pkgset create "${PROJECT}"
    gvm pkgset use "${PROJECT}"
  3. Install pre-commit hooks and dependencies:

    mage installPreCommitHooks
  4. Update and run pre-commit hooks locally:

    mage runPreCommit

Usage

To get started, you will need to:

  1. Create a new repo with this template
  2. Replace all instances of PROJECT_NAME, BIN_NAME, l50, and goproject found throughout the codebase
  3. Customize as needed