buffer

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package buffer provides a thin wrapper around a byte slice as well as portion of the strconv package's zero-allocation formatters.

It is a simplification of the zap package's internal implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer is a thin wrapper around a byte slice.

A Buffer is intended to be constructed via a sync.Pool using Get.

func Get

func Get() *Buffer

Get retrieves a Buffer from a sync.Pool, constructing one if necessary.

The caller must call Buffer.Free on the returned Buffer after using it to ensure that it's returned to the sync.Pool.

func (*Buffer) AppendByte

func (b *Buffer) AppendByte(c byte)

AppendByte writes a single byte to the Buffer.

func (*Buffer) AppendInt

func (b *Buffer) AppendInt(i int64)

AppendInt writes an integer to the Buffer, formatted as base-10.

func (*Buffer) AppendString

func (b *Buffer) AppendString(s string)

AppendString writes a string to the Buffer.

func (*Buffer) Cap

func (b *Buffer) Cap() int

Cap returns the capacity of the underlying byte slice.

func (*Buffer) Free

func (b *Buffer) Free()

Free returns the Buffer to a sync.Pool.

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

func (*Buffer) Len

func (b *Buffer) Len() int

Len returns the length of the underlying byte slice.

func (*Buffer) Reset

func (b *Buffer) Reset()

Reset clears the underlying byte slice.

func (*Buffer) String

func (b *Buffer) String() string

String returns a string copy of the underlying byte slice.

Jump to

Keyboard shortcuts

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