by jagger27 · 8y ago · 0 comments
In fact, the only _print function I could get to fail was Fprintf by sending an already closed file. I suppose if it was somehow not allowed to write to stdout the other functions might fail. But I'm not sure.
_, err := fmt.Printf("Hello %d", "world")
fmt.Println(err)
>> Hello %!d(string=world)
>> <nil>To reproduce the key lines here:
os.Stdout.Close()
_, err := fmt.Println("foo")
You can also close stdout from outside the program, use ptrace to cause the write call to fail, or a number of other things.