News for hackers. Stuff that matters.
Re:Go 2 Draft Designs by jagger27 on Tuesday August 28, 2018 @01:43PM (#17860950)
I'm having a hard time making it fail. Even with Printf, in the output it tells you what you did wrong instead of returning an error.

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>
Re:Go 2 Draft Designs by ianlancetaylor on Tuesday August 28, 2018 @04:10PM (#17862425)
Yes, the various fmt.Print functions only return an error if Write on the underlying Writer returns an error.
Re:Go 2 Draft Designs by TheDong on Wednesday August 29, 2018 @01:15PM (#17869932)
Here you go: https://play.golang.org/p/0vGdejrjm5H

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.