Documentation
¶
Index ¶
Constants ¶
View Source
const DefaultSize = 128
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer interface {
// Len returns the number of bytes in the buffer; b.Len() == len(b.Bytes()).
Len() int
// Bytes returns a byte slice with the buffer bytes.
// It is valid for use only until the next buffer mutation.
Bytes() []byte
// Grow grows the buffer and returns an n-byte slice.
// It be should be used directly and is only valid until the next buffer mutation.
//
// Usage:
//
// p := b.Grow(8)
// binary.BigEndian.PutUint64(p, 1234)
//
Grow(n int) []byte
// Write appends bytes from p to the buffer.
//
// Equivalent to:
//
// buf := b.Grow(n)
// copy(buf, p)
//
Write(p []byte) (n int, err error)
// WriteByte writes a byte to the buffer.
WriteByte(b byte) error
// Reset resets the buffer to be empty, but can retain its internal buffer.
Reset()
}
Buffer is a general purpose byte buffer interface.
type Writer ¶
type Writer interface {
// WriteByte writes a byte to the buffer.
WriteByte(c byte) error
// WriteRune writes a rune to the buffer.
WriteRune(r rune) (n int, err error)
// WriteString writes a string to the buffer.
WriteString(s string) (n int, err error)
}
Writer specifies additional methods for writing to a buffer.
Click to show internal directories.
Click to hide internal directories.