You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ntool/ntest/buffer.go

44 lines
689 B
Go

package ntest
import (
"bytes"
"fmt"
)
// Buffer wrap and extends the bytes.Buffer
type Buffer struct {
bytes.Buffer
}
// NewBuffer instance
func NewBuffer() *Buffer {
return &Buffer{}
}
// WriteString rewrite
func (b *Buffer) WriteString(ss ...string) {
for _, s := range ss {
_, _ = b.Buffer.WriteString(s)
}
}
// WriteAny method
func (b *Buffer) WriteAny(vs ...any) {
for _, v := range vs {
_, _ = b.Buffer.WriteString(fmt.Sprint(v))
}
}
// Writeln method
func (b *Buffer) Writeln(s string) {
_, _ = b.Buffer.WriteString(s)
_ = b.Buffer.WriteByte('\n')
}
// ResetAndGet buffer string.
func (b *Buffer) ResetAndGet() string {
s := b.String()
b.Reset()
return s
}