5 // NewWriter returns a new Writer that writes to w
6 // until an error is returned.
7 func NewWriter(w io.Writer) *Writer {
11 // Writer is in an implementation of the
12 // "sticky error writer" pattern as described
13 // in https://blog.golang.org/errors-are-values.
15 // A Writer makes one call
16 // on the underlying writer for each call to Write,
17 // until an error is returned. From that point on,
18 // it makes no calls on the underlying writer,
19 // and returns the same error value every time.
26 // Write makes one call on the underlying writer
27 // if no error has previously occurred.
28 func (w *Writer) Write(buf []byte) (n int, err error) {
32 n, w.err = w.w.Write(buf)
37 // Err returns the first error encountered by Write, if any.
38 func (w *Writer) Err() error {
42 // Written returns the number of bytes written
43 // to the underlying writer.
44 func (w *Writer) Written() int64 {