Help us shape the future of Go! Take the 2026 Go Developer Survey

buffer

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBufferTooSmall error = errors.New("entity too large - buffer too small")

Functions

func NewReader

func NewReader(data []byte) io.ReadCloser

NewReader creates a new reader closer wrapper

func Read

func Read(pool httputil.BufferPool, reader io.Reader) ([]byte, int, error)

Read reads data with buffer Pool

Types

type Pool

type Pool struct {
	Discarded uint64
	Created   uint64
	// contains filtered or unexported fields
}

Pool implementation tries its best to reuse an available slice but will failover ASAP to creating a new slice.

func New

func New(poolMaxSize, bufferSize int) *Pool

New creates a httputil.BufferPool Pool.

func (*Pool) Get

func (p *Pool) Get() (result []byte)

Get returns bytes

func (*Pool) Put

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

Put put data back to the pool

type Reader

type Reader struct {
	Data []byte
	io.Reader
}

Reader represents a reader

func (*Reader) Close

func (r *Reader) Close() error

Close closes reader

Jump to

Keyboard shortcuts

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