gilo/internal/buffer/buffer.go
Timothy J. Warren 1cc35c95a7
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
Move more stuff around
2021-04-02 13:11:54 -04:00

47 lines
739 B
Go

package buffer
import (
"fmt"
"strings"
)
// ----------------------------------------------------------------------------
// !Output Buffer
// ----------------------------------------------------------------------------
type Buffer struct {
buf *strings.Builder
}
func NewBuffer() *Buffer {
var buf strings.Builder
b := new(Buffer)
b.buf = &buf
return b
}
func (b *Buffer) AppendRune(r rune) int {
size, _ := b.buf.WriteRune(r)
return size
}
func (b *Buffer) Append(s string) int {
size, _ := b.buf.WriteString(s)
return size
}
func (b *Buffer) AppendLn(s string) int {
str := fmt.Sprintf("%s\r\n", s)
size, _ := b.buf.WriteString(str)
return size
}
func (b *Buffer) ToString() string {
return b.buf.String()
}