Skip to Content

More Mage and Go: Awesome Mage Repo

I got so wrapped up with Mage and the helpers posts that I didn’t realize that an awesome mage repository already exists with an extensive list of helpers that are already available. It’s a pretty robust list that covers most of the common usages that would be needed. Let’s see what using the mage-extras helpers will do to our mage-example project.

Installing Mage Extras Helpers

We can install it using go get in our project.

go get

go: downloading v0.0.6
go: downloading v0.0.1
go: downloading v0.0.4
go: downloading v0.0.0-20201016144719-6a343cdae81d
go get: added v0.0.6

Now we can start using these in our magefile.go.

Using the Mage Extras in our Magefile

Now we can replace our build task to use one of the mage-extras helpers.

//go:build mage
// +build mage

package main

import (

	mageextras ""

var Default = Build

func Clean() error {
	return sh.Rm("bin")

func Build() error {
	return mageextras.Compile("-o", "./bin/")

func Test() error {
	return mageextras.UnitTest()

func Download() error {

	url := ""
	return dl.GetFile(url, filepath.Join("bin", "random.txt"))

We also added a test execution step that leverages the UnitTest helper.

Wrapping Up

Like I said above, I didn’t realize that many of these helpers already existed, which makes it even nicer that this pattern is already in use. I did stumble across one of the projects that called them spells, which I think is neat. I will check out a few other projects like retool and mageproj, which seem to bring some additional structure to projects.

Thanks for reading,


If you enjoy the content then consider buying me a coffee.