How to debug "exit status 1" error when running exec.Command in Golang -


when run code below:

cmd := exec.command("find", "/", "-maxdepth", "1", "-exec", "wc", "-c", "{}", "\\") var out bytes.buffer cmd.stdout = &out err := cmd.run() if err != nil {     fmt.println(err)     return } fmt.println("result: " + out.string()) 

i getting error:

exit status 1

however not helpful debug exact cause of error.

how more detailed information?

the solution use stderr property of command object. can done this:

cmd := exec.command("find", "/", "-maxdepth", "1", "-exec", "wc", "-c", "{}", "\\") var out bytes.buffer var stderr bytes.buffer cmd.stdout = &out cmd.stderr = &stderr err := cmd.run() if err != nil {     fmt.println(fmt.sprint(err) + ": " + stderr.string())     return } fmt.println("result: " + out.string()) 

running above code, make clear issue is:

exit status 1: find: -exec: no terminating ";" or "+"


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -