I cannot figure the error in the following. package main import ( "io" "os" "os/exec" "strings" )
func Run(args []string) { lf, _ := os.Create("lf.log") defer lf.Close() cmd := exec.Command(args[0], strings.Join(args[1:], " ")) stderr, _ := cmd.StderrPipe() cmd.Start() io.Copy(lf, stderr) cmd.Wait() } func main() { args := []string{"go", "build", "./"} Run(args) } I can execute go build ./ and get an executable. However when I run it I get the following in the logfile: cat lf.log go build ./: unknown command Run 'go help build' for usage. I exected that the "exec" will just execute go build ./ I did rename the exe to something else before running it. Anyone can spot the error? Thanks, srini PS - I am not sure if it matters but I am on a Mac and use go version go1.13.6 darwin/amd64 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a492a5a4-2fc1-4bd4-aadc-ed6ec5e45609%40googlegroups.com.