exec.Command does not register error from Go's own pprof tool -


here code:

cmd := exec.command("go", "tool", "pprof", "-dot", "-lines", "http://google.com") out, err := cmd.output() if err != nil {     panic(err) } println(string(out)) 

when run exact same command in console, see:

$ go tool pprof -dot -lines http://google.com  fetching profile http://google.com/profilez please wait... (30s) server response: 404 not found  

however, go program not register error. oddly, variable out prints empty string , err nil. going on?

to clarify, profiling http://google.com purposefully create error. profile real go application.

the text

fetching profile http://google.com/profilez please wait... (30s) server response: 404 not found  

is written stderr. program captures stdout, empty. consider calling:

out, err := cmd.combinedoutput() 

to grab both stdout , stderr.

cmd.output() , cmd.combinedoutput() return err == nil because command exits status zero. perhaps issue should filed requesting command exit non-zero status.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -