Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBuffer

func NewBuffer() interface{}

NewBuffer creates a new buffer with a default, fixed size (1024)

func String

func String(ctx context.Context, key interface{}) string

String gets a string with the given key from the given context's values

Types

type Buffer

type Buffer struct {

	// contains filtered or unexported fields

}

Buffer is a wrapper around a byte slice, integrated with a pool

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes returns the underlying byte slice

func (*Buffer) Free

func (b *Buffer) Free()

Free returns the Buffer to the associated pool for reuse

func (*Buffer) Reset

func (b *Buffer) Reset()

Reset clears the underlying byte slice, but does not allocate a new array

type Pool

type Pool struct {
	// contains filtered or unexported fields

}

Pool wraps sync.Pool with typesafe returns for *Buffer

func NewPool

func NewPool() Pool

NewPool instantiates a new pool

func (Pool) Get

func (p Pool) Get() *Buffer

Get retrieves an available *Buffer from the pool, or allocates a new one

Source Files