github.com/nikandfor/tlog@v0.21.5-0.20231108111739-3ef89426a96d/low/fmt.go (about)

     1  package low
     2  
     3  const Spaces = "                                                                                                                                "
     4  
     5  type (
     6  	Buf []byte
     7  )
     8  
     9  func (w *Buf) Reset() {
    10  	*w = (*w)[:0]
    11  }
    12  
    13  func (w *Buf) Write(p []byte) (int, error) {
    14  	*w = append(*w, p...)
    15  
    16  	return len(p), nil
    17  }
    18  
    19  func (w *Buf) NewLine() {
    20  	l := len(*w)
    21  	if l == 0 || (*w)[l-1] != '\n' {
    22  		*w = append(*w, '\n')
    23  	}
    24  }
    25  
    26  func (w *Buf) Len() int      { return len(*w) }
    27  func (w *Buf) Bytes() []byte { return *w }