1package mage
2
3var mageTpl = `// +build mage
4
5package main
6
7import (
8	"fmt"
9	"os"
10	"os/exec"
11
12	"github.com/magefile/mage/mg" // mg contains helpful utility functions, like Deps
13)
14
15// Default target to run when none is specified
16// If not set, running mage will list available targets
17// var Default = Build
18
19// A build step that requires additional params, or platform specific steps for example
20func Build() error {
21	mg.Deps(InstallDeps)
22	fmt.Println("Building...")
23	cmd := exec.Command("go", "build", "-o", "MyApp", ".")
24	return cmd.Run()
25}
26
27// A custom install step if you need your bin someplace other than go/bin
28func Install() error {
29	mg.Deps(Build)
30	fmt.Println("Installing...")
31	return os.Rename("./MyApp", "/usr/bin/MyApp")
32}
33
34// Manage your deps, or running package managers.
35func InstallDeps() error {
36	fmt.Println("Installing Deps...")
37	cmd := exec.Command("go", "get", "github.com/stretchr/piglatin")
38	return cmd.Run()
39}
40
41// Clean up after yourself
42func Clean() {
43	fmt.Println("Cleaning...")
44	os.RemoveAll("MyApp")
45}
46`
47