building args cmd works, need content

This commit is contained in:
Dan Ballard 2014-12-09 08:07:27 -08:00
parent a8580683de
commit 4d9d215c43
1 changed files with 7 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"log" "log"
"os"
"os/exec" "os/exec"
) )
@ -15,9 +16,13 @@ var buildCmd = &Command{
} }
func buildRun(cmd *Command, args ...string) { func buildRun(cmd *Command, args ...string) {
out, err := exec.Command("go", "build", "-ldflags", fmt.Sprintf("\"-X main.Build.Date %s main.Build.GitHash %s main.Build.Num %d\"", "2014-12-08", "a1b2c3d4", 107)).Output() mycmd := exec.Command("go", "build", "-ldflags", fmt.Sprintf("-X main.Build.Date %s -X main.Build.GitHash %s -X main.Build.Num %d\"", "2014-12-08", "a1b2c3d4", 107))
fmt.Println(mycmd.Args)
fmt.Println(mycmd.Env)
mycmd.Stderr = os.Stderr
mycmd.Stdout = os.Stdout
err := mycmd.Run()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
fmt.Printf("%s\n", out)
} }