Skip to content

Instantly share code, notes, and snippets.

@carolynvs
Last active January 24, 2021 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carolynvs/b82a17580d4c50abc38529ee8fdc79ac to your computer and use it in GitHub Desktop.
Save carolynvs/b82a17580d4c50abc38529ee8fdc79ac to your computer and use it in GitHub Desktop.
example magefile
// +build mage
package main
import (
"github.com/carolynvs/magex/pkg"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
)
// Default target to run when none is specified
// If not set, running mage will list available targets
var Default = Build
// Compile and lint the cli
func Build() error {
mg.Deps(Lint)
return sh.RunV("go", "build", "./...")
}
// nit the hell outta my code
func Lint() error {
mg.Deps(EnsureGoLint)
return sh.RunV("golint", "./...")
}
// Install golint if needed
func EnsureGoLint() error {
return pkg.EnsurePackage("golang.org/x/lint/golint", "")
}
// Install Mage if necessary
func EnsureMage() error {
return pkg.EnsureMage("v1.11.0")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment