gotest.tools/gotestsum@v1.11.0/internal/dotwriter/writer.go (about) 1 /* 2 Package dotwriter implements a buffered Writer for updating progress on the 3 terminal. 4 */ 5 package dotwriter 6 7 import ( 8 "bytes" 9 "io" 10 ) 11 12 // ESC is the ASCII code for escape character 13 const ESC = 27 14 15 // Writer buffers writes until Flush is called. Flush clears previously written 16 // lines before writing new lines from the buffer. 17 // The main logic is platform specific, see the related files. 18 type Writer struct { 19 out io.Writer 20 buf bytes.Buffer 21 lineCount int 22 } 23 24 // New returns a new Writer 25 func New(out io.Writer) *Writer { 26 return &Writer{out: out} 27 } 28 29 // Write saves buf to a buffer 30 func (w *Writer) Write(buf []byte) (int, error) { 31 return w.buf.Write(buf) 32 }