On Wed, Aug 12, 2015 at 10:21 AM, nicolas riesch
<
nicolas...@gmail.com> wrote:
>
> I am a little confused with the buffering mode of Stdout, and fmt.Print
> behaviour.
>
> If I am not mistaken, it seems that os.Stdout is not line buffered.
> In fact, it is not buffered at all, as shown here :
>
>
http://play.golang.org/p/8IrFdcETpt
That is correct. os.Stdout is not buffered.
> Is the buffering mode of Stdin, Stdout and Stderr documented somewhere ? I
> haven't found so far ...
It's never really seemed necessary to explicitly document that they
are unbuffered. They are documented as being *os.File. A *os.File is
not buffered.
> When the output of a Go program is redirected to a file, is there some block
> buffering taking place ?
Not by the Go program. The operating system presumably does it.
> If I want to create a "line buffered" Writer wrapping os.Stdout, f :=
> bufio.NewWriter(os.Stdout) is not enough.
> I should create a custom Writer type, with a Write(s) method calling Flush()
> if s contains '\n', correct ?
Correct.
Ian