Home

Awesome

scripts-to-rule-them-all-go

Inspired from the 2015 repo for "Scripts to Rule Them All", this applies that same concept but with using a more modern toolchain like Go and Mage. Mage provides a Go based task runner that can replace makefiles, custom bash/python/powershell scripts, and instead provide a cross-platform common set of commands to run a project.

2022-03 ๐Ÿšง WIP - Bringing in a few more examples. It's ready to use for basics though!

Why Mage

Why This Template?

This project is a template to help bootstrap a new project with a few things that normally result in more setup work. I've tended to standardize on a few key things.

Normal tasks:

Included & Prebaked

You Want More?

๐Ÿ‘‰ Checkout magetools

I've been steadily baking automation tasks that are tested and reusable in there. Most of the tasks self-setup any tooling as well.

Custom

Example Output

Running mage in a brand new project.

โšก Core Mage Tasks

Targets:
  clean                  up after yourself.
  gittools:init          โš™๏ธ Init runs all required steps to use this package.
  go:doctor              ๐Ÿฅ Doctor will provide config details.
  go:fix                 ๐Ÿ”Ž Run golangci-lint and apply any auto-fix.
  go:fmt                 โœจ Fmt runs gofumpt.
  go:init                โš™๏ธ Init runs all required steps to use this package.
  go:lint                ๐Ÿ”Ž Run golangci-lint without fixing.
  go:lintConfig          ๐Ÿฅ LintConfig will return output of golangci-lint config.
  go:test                ๐Ÿงช Run go test.
  go:testSum             ๐Ÿงช Run gotestsum (Params: Path just like you pass to go test, ie ./..., pkg/, etc ).
  go:tidy                ๐Ÿงน Tidy tidies.
  go:wrap                โœจ Wrap runs golines powered by gofumpt.
  init                   runs multiple tasks to initialize all the requirements for running a project for a new contributor.
  precommit:commit       ๐Ÿงช Commit runs pre-commit checks using pre-commit.
  precommit:init         โš™๏ธ Init configures precommit hooks.
  precommit:prepush      ๐Ÿงช Push runs pre-push checks using pre-commit.
  precommit:uninstall    โœ– Uninstall removes the pre-commit hooks.
  secrets:detect         ๐Ÿ” Detect scans for secret violations with gitleaks without git consideration.
  secrets:protect        ๐Ÿ” Protect scans the staged artifacts for violations.

Template

You can use this as a template to get started with a project ready to run using Mage.

Setup

Using Go (won't have version info embedded)

go install github.com/magefile/mage@latest

Note

Optional: maintain //go:build mage to avoid impacting test coverage reports.

I've added this to the tags for language server build to recognize so you can use code completion.