On Mon, Jan 13, 2020 at 3:07 AM Ian Lance Taylor <i...@golang.org> wrote:
> The difference between os.Stdout and other files is: if writing to > os.Stdout fails, where are you going to report the error? You could > report it to os.Stderr, of course, but if os.Stdout doesn't work then > it is very likely that os.Stderr also doesn't work. I'm not sure about the "very likely". It is extremely common to redirect stdout to a file and leave stderr on the terminal (as in my example). Even if they are both regular files, they could be on different mount points (although less likely). More importantly, in a non-interactive situation the exit status is often used to make decisions, and it is effective regardless of a bad stderr. Also, from your reasoning one could infer that it's not necessary to report os.Stdout.Write errors either, is that correct? So my personal general guideline is: always check for, and report, > errors on files opened for writing, but don't worry about os.Stdout. > Thanks, good to know. This is what I've been doing so far, but only because the issue with os.Stdout never occurred to me. -- 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/CAEvMKD9yz8BgmyOOLdpxddkzfqJ5AcQ%2B%3DWgjVnTvMgqQe%2BBNYA%40mail.gmail.com.