It looks like you have a bug in your code. "In tests, standard output is accumulated during execution and dumped to standard output when done."
"Example functions may include a concluding line comment that begins with "Output:" and is compared with the standard output of the function when the tests are run." In ExampleMain(), you improperly used the os.Stdout variable value as of the testing package initialization. In ExampleMain2(), you properly used the os.Stdout variable value as of when the function was run. testing package https://pkg.go.dev/testing@latest Peter On Sunday, May 1, 2022 at 8:03:29 PM UTC-4 psi....@gmail.com wrote: > this caught me out, is it a bug? > > https://go.dev/play/p/atJb8dZHoqi > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/f264f884-0e72-4095-a583-17ea65f10fa8n%40googlegroups.com.