bytes

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2016 License: BSD-2-Clause, MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MuBuffer

type MuBuffer struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

MuBuffer defines a thread-safe bytes buffer. The zero value for MuBuffer is an empty buffer ready to use.

func NewBuffer

func NewBuffer(buf []byte) *MuBuffer

NewBuffer creates and initializes a new MuBuffer using buf as its initial contents. It is intended to prepare a MuBuffer to read existing data. It can also be used to size the internal buffer for writing. To do that, buf should have the desired capacity but a length of zero.

In most cases, new(MuBuffer) (or just declaring a MuBuffer variable) is sufficient to initialize a MuBuffer.

func NewBufferString

func NewBufferString(s string) *MuBuffer

NewBufferString creates and initializes a new MuBuffer using string s as its initial contents. It is intended to prepare a buffer to read an existing string.

In most cases, new(MuBuffer) (or just declaring a MuBuffer variable) is sufficient to initialize a MuBuffer.

func (*MuBuffer) Grow

func (b *MuBuffer) Grow(n int)

Grow grows the buffer's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to the buffer without another allocation. If n is negative, Grow will panic. If the buffer can't grow it will panic with ErrTooLarge.

func (*MuBuffer) Truncate

func (b *MuBuffer) Truncate(n int)

Truncate discards all but the first n unread bytes from the buffer but continues to use the same allocated storage. It panics if n is negative or greater than the length of the buffer.

func (*MuBuffer) Write

func (b *MuBuffer) Write(p []byte) (n int, err error)

Write appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will panic with ErrTooLarge.

func (*MuBuffer) WriteByte

func (b *MuBuffer) WriteByte(c byte) error

WriteByte appends the byte c to the buffer, growing the buffer as needed. The returned error is always nil, but is included to match bufio.Writer's WriteByte. If the buffer becomes too large, WriteByte will panic with ErrTooLarge.

func (*MuBuffer) WriteString

func (b *MuBuffer) WriteString(s string) (n int, err error)

WriteString appends the contents of s to the buffer, growing the buffer as needed. The return value n is the length of s; err is always nil. If the buffer becomes too large, WriteString will panic with ErrTooLarge.

Jump to

Keyboard shortcuts

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