Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FastXor ¶
func FastXor(dst, a, b []byte)
Used to xor byte slices a and b, writing the result into dst. Based on github.com/golang/go/issues/31586#issuecomment-487436401. Panics b and dst aren't at least as long as a. It's valid for dst to be the same as either a or b. Benchmarks on my machine (tm) indicate that this is over 3x faster than SimpleXor alone for 1 MB slices, though this may change depending on architecture.
Types ¶
type SeekableBuffer ¶
type SeekableBuffer struct { // This will grow as needed, based on either the farthest write or seek // offset. Writing past the end of this will increase its size. Seeking // past the end will add zeros to the necessary size. Data []byte // The current read or write offset in the file. It's an error to read past // the end of the data, but writing pas Offset int64 }
This type implements an in-memory io.Reader, io.Writer, and io.Seeker.
func NewSeekableBuffer ¶
func NewSeekableBuffer() *SeekableBuffer
func (*SeekableBuffer) Read ¶
func (b *SeekableBuffer) Read(dst []byte) (int, error)
Provides the normal io.Reader interface.
func (*SeekableBuffer) Seek ¶
func (b *SeekableBuffer) Seek(offset int64, whence int) (int64, error)
Sets the next read or write offset to the specified offset, returning the new offset. Expands the underlying buffer if the new offset is greater than its current size. Returns an error without changing the current offset if an error occurs.