buffer

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Unlicense Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncBuffer

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

AsyncBuffer is like bytes.Buffer but it can safely be used from multiple goroutines at once. But it does not implement every bytes.Buffer method. It adds ReadAll() and ReadAllString() methods for atomic operations. It is useful as a logging destination inside of automated tests.

'new(buffer.AsyncBuffer)' should be used to create an AsyncBuffer. You can also just declare a buffer.AsyncBuffer so long as you are careful to never make a copy of it.

func (*AsyncBuffer) Bytes

func (ab *AsyncBuffer) Bytes() []byte

func (*AsyncBuffer) Len

func (ab *AsyncBuffer) Len() int

func (*AsyncBuffer) ReadAll

func (ab *AsyncBuffer) ReadAll() []byte

ReadAll() is similar to Bytes() except it also atomically Reset()s the buffer and the returned slice is a copy that is not changed by subsequent buffer operations.

func (*AsyncBuffer) ReadAllString

func (ab *AsyncBuffer) ReadAllString() string

ReadAllString() is similar to String() except it also atomically Reset()s the buffer.

func (*AsyncBuffer) ReadBytes

func (ab *AsyncBuffer) ReadBytes(delim byte) ([]byte, error)

func (*AsyncBuffer) ReadString

func (ab *AsyncBuffer) ReadString(delim byte) (string, error)

func (*AsyncBuffer) Reset

func (ab *AsyncBuffer) Reset()

func (*AsyncBuffer) String

func (ab *AsyncBuffer) String() string

func (*AsyncBuffer) Truncate

func (ab *AsyncBuffer) Truncate(n int)

func (*AsyncBuffer) Write

func (ab *AsyncBuffer) Write(p []byte) (int, error)

type AsyncBuilder

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

AsyncBuilder is like strings.Builder but it can safely be used from multiple goroutines at once. It is useful as a logging destination inside of automated tests if you only ever want the entire recent log contents [since the last Reset()] as a single string.

'new(buffer.AsyncBuilder)' should be used to create an AsyncBuilder. You can also just declare a buffer.AsyncBuilder so long as you are careful to never make a copy of it.

func (*AsyncBuilder) Grow

func (sb *AsyncBuilder) Grow(n int)

func (*AsyncBuilder) Len

func (sb *AsyncBuilder) Len() int

func (*AsyncBuilder) ReadAll

func (sb *AsyncBuilder) ReadAll() string

ReadAll() is like String() but it also atomically Reset()s the builder.

func (*AsyncBuilder) Reset

func (sb *AsyncBuilder) Reset()

func (*AsyncBuilder) String

func (sb *AsyncBuilder) String() string

func (*AsyncBuilder) Write

func (sb *AsyncBuilder) Write(p []byte) (int, error)

func (*AsyncBuilder) WriteByte

func (sb *AsyncBuilder) WriteByte(c byte) error

func (*AsyncBuilder) WriteRune

func (sb *AsyncBuilder) WriteRune(r rune) (int, error)

func (*AsyncBuilder) WriteString

func (sb *AsyncBuilder) WriteString(s string) (int, error)

Jump to

Keyboard shortcuts

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