Examples do not capture stdout when os.Stdout is assigned to a variable outside the example body:
// foo_test.go
package foo
import "os"
var f = os.Stdout
func Example() {
f.WriteString("a")
// Output:
// a
}
$ go test
a--- FAIL: Example (0.00s)
got:
want:
a
FAIL
exit status 1