Documentation ¶
Overview ¶
Package iofmt contains various IO utilities used for formatting output.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LineWriter ¶ added in v0.0.11
func LineWriter(w io.Writer) io.WriteCloser
LineWriter returns an io.WriteCloser that only calls w.Write with complete lines. This can be used to make it less likely (without locks) for lines to interleave, for example if you are concurrently writing lines of text to os.Stdout. This is particularly useful when composed with PrefixWriter.
// Full lines will be written to os.Stdout, so they will be less likely to // be interleaved with other output. linew := LineWriter(os.Stdout) defer func() { _ = linew.Close() // Handle the possible error. }() w := PrefixWriter(linew, "my-prefix: ")
Close will write any remaining partial line to the underlying writer.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.