buffer

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package buffer provides a pooled *[]byte for zero-alloc formatting in hot paths. Consumers acquire a reusable buffer via Get and return it via Put so steady-state allocations tend toward zero. A buffer is its caller's from Get until Put and must not be touched after Put. It is a thin byte-slice specialisation over internal/kernel/concur/recycler.CappedPool (ADR 0010): the recycling mechanism lives in recycler, the 64-KiB capacity threshold and the *[]byte type live here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get() *[]byte

Get borrows a reusable byte buffer with zero length and capacity >= initialCap.

func Put

func Put(b *[]byte)

Put returns a buffer to the pool after use; the recycler truncates its length and drops it when cap exceeds maxRetain. A nil argument is a safe no-op so call sites can always defer Put — the generic CappedPool cannot nil-check a pointer-like T, so the guard lives here.

Put ends the caller's ownership of b. Once it returns, neither *b nor the bytes it points at may be read or written — not even len(*b) — and b must not be Put again: the pool may already have handed b to another goroutine, which writes both as its own. Copy out whatever is still needed before Put.

Types

This section is empty.

Jump to

Keyboard shortcuts

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