Documentation ¶
Index ¶
- type Buffer
- func (b *Buffer) Append(data []byte) *Buffer
- func (b *Buffer) AppendBytes(bytes ...byte) *Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Clear() *Buffer
- func (b *Buffer) FillFrom(reader io.Reader) (int, error)
- func (b *Buffer) IsEmpty() bool
- func (b *Buffer) IsFull() bool
- func (b *Buffer) Len() int
- func (b *Buffer) Prepend(data []byte) *Buffer
- func (b *Buffer) Read(data []byte) (int, error)
- func (b *Buffer) Release()
- func (b *Buffer) Slice(from, to int) *Buffer
- func (b *Buffer) SliceBack(offset int) *Buffer
- func (b *Buffer) SliceFrom(from int) *Buffer
- func (b *Buffer) Write(data []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct { Value []byte // contains filtered or unexported fields }
Buffer is a recyclable allocation of a byte array. Buffer.Release() recycles the buffer into an internal buffer pool, in order to recreate a buffer more quickly.
func NewBuffer ¶
func NewBuffer() *Buffer
NewBuffer creates a Buffer with 8K bytes of arbitrary content.
func NewLargeBuffer ¶
func NewLargeBuffer() *Buffer
NewLargeBuffer creates a Buffer with 64K bytes of arbitrary content.
func NewSmallBuffer ¶
func NewSmallBuffer() *Buffer
NewSmallBuffer creates a Buffer with 1K bytes of arbitrary content.
func (*Buffer) AppendBytes ¶
AppendBytes appends one or more bytes to the end of the buffer.
func (*Buffer) Clear ¶
Clear clears the content of the buffer, results an empty buffer with Len() = 0.
func (*Buffer) Prepend ¶ added in v1.9.1
Prepend prepends bytes in front of the buffer. Caller must ensure total bytes prepended is no more than 16 bytes.
func (*Buffer) Release ¶
func (b *Buffer) Release()
Release recycles the buffer into an internal buffer pool.
func (*Buffer) SliceBack ¶ added in v1.9.1
SliceBack extends the Buffer to its front by offset bytes. Caller must ensure cumulated offset is no more than 16.