29 lines
		
	
	
		
			610 B
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			610 B
		
	
	
	
		
			Go
		
	
	
	
package main
 | 
						|
 | 
						|
import (
 | 
						|
	"fmt"
 | 
						|
	"log"
 | 
						|
	"os"
 | 
						|
	"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) {
 | 
						|
	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 {
 | 
						|
		log.Fatal(err)
 | 
						|
	}
 | 
						|
}
 |