bytes

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLength   = errors.New("invalid length")
	ErrInvalidPosition = errors.New("invalid position")
	ErrNotEnougth      = errors.New("bytes not enougth")
)
View Source
var Pool interface {
	Get() []byte
	GetN(size int) []byte
	Put(b []byte)
} = NewPool(64)

Pool is the default instance of []byte pool. User can customize a Pool implementation and reset this instance if needed.

Functions

func NewPool added in v1.1.1

func NewPool(minSize int) *bufferPool

NewPool creates and returns a bufferPool instance. All slice created by this instance has an initial cap of minSize.

Types

type Buffer

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

Buffer .

func NewBuffer

func NewBuffer() *Buffer

NewBuffer .

func (*Buffer) Append

func (bb *Buffer) Append(b []byte)

Append .

func (*Buffer) Head

func (bb *Buffer) Head(n int) ([]byte, error)

Head .

func (*Buffer) Len

func (bb *Buffer) Len() int

Len .

func (*Buffer) OnRelease

func (bb *Buffer) OnRelease(onRelease func(b []byte))

func (*Buffer) Pop

func (bb *Buffer) Pop(n int) ([]byte, error)

Pop .

func (*Buffer) Push

func (bb *Buffer) Push(b []byte)

Push .

func (*Buffer) Read

func (bb *Buffer) Read(n int) ([]byte, error)

Read .

func (*Buffer) ReadAll

func (bb *Buffer) ReadAll() ([]byte, error)

ReadAll .

func (*Buffer) Reset

func (bb *Buffer) Reset()

Reset .

func (*Buffer) Sub

func (bb *Buffer) Sub(from, to int) ([]byte, error)

Sub .

func (*Buffer) Write

func (bb *Buffer) Write(b []byte)

Write .

Jump to

Keyboard shortcuts

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