Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
func captureStdout(f func()) string {
tempFile, _ := ioutil.TempFile("", "stdout")
oldStdout := os.Stdout
os.Stdout = tempFile
os.Stdout = oldStdout
b, _ := ioutil.ReadFile(tempFile.Name())
return string(b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.