gopkg.in/tools/godep.v42@v42.0.0-20151223001600-f221061cd941/util.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "os/exec" 6 ) 7 8 // Runs a command in dir. 9 // The name and args are as in exec.Command. 10 // Stdout, stderr, and the environment are inherited 11 // from the current process. 12 func runIn(dir, name string, args ...string) error { 13 _, err := runInWithOutput(dir, name, args...) 14 return err 15 } 16 17 func runInWithOutput(dir, name string, args ...string) (string, error) { 18 c := exec.Command(name, args...) 19 c.Dir = dir 20 o, err := c.CombinedOutput() 21 22 if debug { 23 fmt.Printf("execute: %+v\n", c) 24 fmt.Printf(" output: %s\n", string(o)) 25 } 26 27 return string(o), err 28 }