Skip to content

Commit

Permalink
mage builds support '-gocmd'
Browse files Browse the repository at this point in the history
  • Loading branch information
batmac committed Jun 24, 2024
1 parent bdae15c commit 9e47f9d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions magefiles/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var Default = BuildDefaultAndTest
var (
defaultBuildArgs = []string{"build"}
binaryName = "ccat"
goBin = mg.GoCmd()
)

func init() {
Expand Down Expand Up @@ -65,7 +66,7 @@ func build(tags string) error {
buildArgs := defaultBuildArgs
buildArgs = append(buildArgs, "-ldflags", ldFlags(tags), "-tags", tags)

if err := sh.RunWithV(nil, "go", buildArgs...); err != nil {
if err := sh.RunWithV(nil, goBin, buildArgs...); err != nil {
return err
}

Expand Down Expand Up @@ -115,7 +116,7 @@ func Install() error {
// go mod download
func InstallDeps() error {
stepPrintln("Installing Deps...")
if err := sh.RunV("go", "mod", "download"); err != nil {
if err := sh.RunV(goBin, "mod", "download"); err != nil {
return err
}
stepOKPrintln("Installing Deps OK")
Expand All @@ -126,7 +127,7 @@ func InstallDeps() error {
func VerifyDeps() error {
mg.Deps(InstallDeps)
stepPrintln("Verifying Deps...")
if err := sh.Run("go", "mod", "verify"); err != nil {
if err := sh.Run(goBin, "mod", "verify"); err != nil {
return err
}
stepOKPrintln("Verifying Deps OK")
Expand All @@ -146,7 +147,7 @@ func Clean() error {
func TestGo() error {
mg.Deps(InstallDeps)
stepPrintln("Testing Go...")
r, err := sh.Output("go", "test", "./...")
r, err := sh.Output(goBin, "test", "./...")
if mg.Verbose() {
fmt.Println(r, "\n ")
}
Expand Down

0 comments on commit 9e47f9d

Please sign in to comment.