buffer

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package buffer provides a thin wrapper around a byte slice. Unlike the standard library's bytes.BytesBuffer, it supports a portion of the strconv package's zero-allocation formatters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BytesBuffer

type BytesBuffer struct {
	// contains filtered or unexported fields
}

BytesBuffer is a thin wrapper around a byte slice. It's intended to be pooled, so the only way to construct one is via a BytesBufferPool.

func (*BytesBuffer) AppendBool

func (b *BytesBuffer) AppendBool(v bool)

AppendBool appends a bool to the underlying buffer.

func (*BytesBuffer) AppendByte

func (b *BytesBuffer) AppendByte(v byte)

AppendByte writes a single byte to the BytesBuffer.

func (*BytesBuffer) AppendBytes

func (b *BytesBuffer) AppendBytes(bs []byte)

AppendBytes writes bytes to the BytesBuffer.

func (*BytesBuffer) AppendFloat

func (b *BytesBuffer) AppendFloat(f float64, bitSize int)

AppendFloat appends a float to the underlying buffer. It doesn't quote NaN or +/- Inf.

func (*BytesBuffer) AppendInt

func (b *BytesBuffer) AppendInt(i int64)

AppendInt appends an integer to the underlying buffer (assuming base 10).

func (*BytesBuffer) AppendString

func (b *BytesBuffer) AppendString(s string)

AppendString writes a string to the BytesBuffer.

func (*BytesBuffer) AppendTime

func (b *BytesBuffer) AppendTime(t time.Time, format string)

AppendTime appends a time to the underlying buffer.

func (*BytesBuffer) AppendUint

func (b *BytesBuffer) AppendUint(i uint64)

AppendUint appends an unsigned integer to the underlying buffer (assuming base 10).

func (*BytesBuffer) Bytes

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

Bytes returns a mutable reference to the underlying byte slice.

func (*BytesBuffer) Cap

func (b *BytesBuffer) Cap() int

Cap returns the capacity of the underlying byte slice.

func (*BytesBuffer) Free

func (b *BytesBuffer) Free()

Free returns the BytesBuffer to its BytesBufferPool. Callers must not retain references to the BytesBuffer after calling Free.

func (*BytesBuffer) Len

func (b *BytesBuffer) Len() int

Len returns the length of the underlying byte slice.

func (*BytesBuffer) Reset

func (b *BytesBuffer) Reset()

Reset resets the underlying byte slice. Subsequent writes re-use the slice's backing array.

func (*BytesBuffer) String

func (b *BytesBuffer) String() string

String returns a string copy of the underlying byte slice.

func (*BytesBuffer) Write

func (b *BytesBuffer) Write(bs []byte) (int, error)

Write implements io.Writer.

type BytesBufferPool

type BytesBufferPool struct {
	// contains filtered or unexported fields
}

A BytesBufferPool is a type-safe wrapper around a sync.BytesBufferPool.

func GlobalBytesPool

func GlobalBytesPool() *BytesBufferPool

GlobalBytesPool returns the global buffer pool.

func NewBytesPool

func NewBytesPool() BytesBufferPool

NewBytesPool constructs a new BytesBufferPool.

func (BytesBufferPool) Get

func (p BytesBufferPool) Get() *BytesBuffer

Get retrieves a BytesBuffer from the pool, creating one if necessary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL