buffer

package
v1.1.14 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool implements httputil.Pool backed by a sync.Pool internally. It reduces allocations for large response bodies by reusing byte slices, thus lowering GC pressure.

func NewPool

func NewPool(minSize, maxSize int) *Pool

NewPool creates a new Pool that returns buffers of at least minSize bytes. Buffers that grow beyond maxSize will be discarded.

Both numbers must be positive, or else the function panics; minSize will be clamped by maxSize.

func (*Pool) Get

func (b *Pool) Get() []byte

Get returns a reusable buffer slice.

func (*Pool) Put

func (b *Pool) Put(buf []byte)

Put returns the buffer to the pool unless it grew beyond the size limit.

Jump to

Keyboard shortcuts

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