How can stdout be captured or suppressed for Go testing?
I am trying to teach myself go(lang) testing. In the code below, myshow.LoadPath prints lots of information to
Not exactly what you are asking for but still might be helpful.
You can use t.Log
(http://golang.org/pkg/testing/#T.Log) and t.Logf
(http://golang.org/pkg/testing/#T.Logf) methods in the test method. The output will be printed only if the test fails or the -test.v
flag is set.
I also would suggest to use log
package to print to the console in myshow.LoadPath
. Then you can disable (or capture) the output in the test by setting custom writer using log.SetOutput