zap: go.uber.org/zap/buffer Index | Files

package buffer

import "go.uber.org/zap/buffer"

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

Index

Package Files

buffer.go pool.go

type Buffer Uses

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

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

func (*Buffer) AppendBool Uses

func (b *Buffer) AppendBool(v bool)

AppendBool appends a bool to the underlying buffer.

func (*Buffer) AppendByte Uses

func (b *Buffer) AppendByte(v byte)

AppendByte writes a single byte to the Buffer.

func (*Buffer) AppendFloat Uses

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

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

func (*Buffer) AppendInt Uses

func (b *Buffer) AppendInt(i int64)

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

func (*Buffer) AppendString Uses

func (b *Buffer) AppendString(s string)

AppendString writes a string to the Buffer.

func (*Buffer) AppendUint Uses

func (b *Buffer) AppendUint(i uint64)

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

func (*Buffer) Bytes Uses

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

Bytes returns a mutable reference to the underlying byte slice.

func (*Buffer) Cap Uses

func (b *Buffer) Cap() int

Cap returns the capacity of the underlying byte slice.

func (*Buffer) Free Uses

func (b *Buffer) Free()

Free returns the Buffer to its Pool.

Callers must not retain references to the Buffer after calling Free.

func (*Buffer) Len Uses

func (b *Buffer) Len() int

Len returns the length of the underlying byte slice.

func (*Buffer) Reset Uses

func (b *Buffer) Reset()

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

func (*Buffer) String Uses

func (b *Buffer) String() string

String returns a string copy of the underlying byte slice.

func (*Buffer) TrimNewline Uses

func (b *Buffer) TrimNewline()

TrimNewline trims any final "\n" byte from the end of the buffer.

func (*Buffer) Write Uses

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

Write implements io.Writer.

type Pool Uses

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

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

func NewPool Uses

func NewPool() Pool

NewPool constructs a new Pool.

func (Pool) Get Uses

func (p Pool) Get() *Buffer

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

Package buffer imports 2 packages (graph) and is imported by 33 packages. Updated 2018-06-29. Refresh now. Tools for package owners.