Can a process read its own "standard out" stream?
Yes, You may use os.Pipe()
then process it yourself:
tmp := os.Stdout
r, w, err := os.Pipe()
if err != nil {
panic(err)
}
os.Stdout = w
Or divert os.Stdout
to a another file or strings.Builder
.
Here is the detailed answer:
In Go, how do I capture stdout of a function into a string?