warren/cmd_build.go

29 lines
610 B
Go
Raw Normal View History

package main
2014-12-09 07:54:35 +00:00
import (
"fmt"
"log"
2014-12-09 16:07:27 +00:00
"os"
2014-12-09 07:54:35 +00:00
"os/exec"
)
var buildCmd = &Command{
Name: "build",
Usage: "",
Summary: "build the go server in the current directory",
Help: `build extended help here...`,
Run: buildRun,
}
func buildRun(cmd *Command, args ...string) {
2014-12-09 16:07:27 +00:00
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()
2014-12-09 07:54:35 +00:00
if err != nil {
log.Fatal(err)
}
}