Documentation
¶
Overview ¶
Package memstream is an expandable ReadWriteSeeker for Golang that works with an internally managed byte buffer. Operation is usage is intended to be seamless and smooth.
In situations where the maximum read/write sizes are known, a fixed []byte/byte buffer will likely offer better performance.
Index ¶
Constants ¶
const DefaultCapacity = 512
DefaultCapacity is the size in bytes of a new MemoryStream's backing buffer
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoryStream ¶
type MemoryStream struct {
// contains filtered or unexported fields
}
MemoryStream is a memory-based, automatically resizing stream that can easily fill the role of any file-based IO.
func NewCapacity ¶
func NewCapacity(cap int) *MemoryStream
NewCapacity starts the returned MemoryStream with the given capacity
func (*MemoryStream) Bytes ¶
func (m *MemoryStream) Bytes() []byte
Bytes returns a copy of ALL valid bytes in the stream, regardless of the current position.
func (*MemoryStream) Read ¶
func (m *MemoryStream) Read(p []byte) (n int, err error)
Read puts up to len(p) bytes into p. Will return the number of bytes read.
func (*MemoryStream) Rewind ¶
func (m *MemoryStream) Rewind() (int64, error)
Rewind returns the stream to the beginning
func (*MemoryStream) Seek ¶
func (m *MemoryStream) Seek(offset int64, whence int) (int64, error)
Seek sets the offset for the next Read or Write to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. Seek returns the new offset and an error, if any.
Seeking to a negative offset is an error. Seeking to any positive offset is legal. If the location is beyond the end of the current length, the position will be placed at length.