Documentation
¶
Index ¶
- Variables
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Peek(length int) ([]byte, error)
- func (b *Buffer) ReadBool() bool
- func (b *Buffer) ReadBytes(length int) []byte
- func (b *Buffer) ReadFloat32() float32
- func (b *Buffer) ReadFloat64() float64
- func (b *Buffer) ReadInt() int
- func (b *Buffer) ReadInt8() int8
- func (b *Buffer) ReadInt16() int16
- func (b *Buffer) ReadInt32() int32
- func (b *Buffer) ReadInt64() int64
- func (b *Buffer) ReadString() string
- func (b *Buffer) ReadUInt() uint
- func (b *Buffer) ReadUInt8() uint8
- func (b *Buffer) ReadUInt16() uint16
- func (b *Buffer) ReadUInt32() uint32
- func (b *Buffer) ReadUInt64() uint64
- func (b *Buffer) WriteBool(i bool)
- func (b *Buffer) WriteBytes(bytes []byte)
- func (b *Buffer) WriteFloat32(i float32)
- func (b *Buffer) WriteFloat64(i float64)
- func (b *Buffer) WriteInt(i int)
- func (b *Buffer) WriteInt8(i int8)
- func (b *Buffer) WriteInt16(i int16)
- func (b *Buffer) WriteInt32(i int32)
- func (b *Buffer) WriteInt64(i int64)
- func (b *Buffer) WriteString(i string)
- func (b *Buffer) WriteUInt(i uint)
- func (b *Buffer) WriteUInt8(i uint8)
- func (b *Buffer) WriteUInt16(i uint16)
- func (b *Buffer) WriteUInt32(i uint32)
- func (b *Buffer) WriteUInt64(i uint64)
Constants ¶
This section is empty.
Variables ¶
var NonPrimitiveTypeError error = errors.New("Type provided to read/write does not fit inside 8 bytes.")
NonPrimitiveTypeError represents an error where the user provided a non-primitive data type for reading/writing
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a utility type which implements a very basic binary protocol for writing core go types.
func NewBuffer ¶
func NewBuffer() *Buffer
NewBuffer creates a new Buffer instance using LittleEndian ByteOrder.
func NewBufferFrom ¶
NewBufferFrom creates a new Buffer instance using the remaining unread data from the provided Buffer instance. The new buffer assumes ownership of the underlying data.
func NewBufferFromBytes ¶
NewBufferFromBytes creates a new Buffer instance using the provided byte slice. The new buffer assumes ownership of the byte slice.
func NewBufferFromReader ¶
NewBufferFromReader creates a new Buffer instance using the provided io.Reader. This buffer is set to read-only.
func (*Buffer) Bytes ¶
Bytes returns the unread portion of the underlying buffer storage. If the buffer was created with an `io.Reader`, then the remaining unread bytes are drained into a byte slice and returned.
func (*Buffer) ReadBytes ¶
ReadBytes reads the specified length from the buffer and returns the byte slice.
func (*Buffer) ReadFloat32 ¶
ReadFloat32 reads a float32 value from the buffer.
func (*Buffer) ReadFloat64 ¶
ReadFloat64 reads a float64 value from the buffer.
func (*Buffer) ReadString ¶
ReadString reads a uint16 value from the buffer representing the string's length, then uses the length to extract the exact length []byte representing the string.
func (*Buffer) ReadUInt16 ¶
ReadUInt16 reads a uint16 value from the buffer.
func (*Buffer) ReadUInt32 ¶
ReadUInt32 reads a uint32 value from the buffer.
func (*Buffer) ReadUInt64 ¶
ReadUInt64 reads a uint64 value from the buffer.
func (*Buffer) WriteBytes ¶
WriteBytes writes the contents of the byte slice to the buffer.
func (*Buffer) WriteFloat32 ¶
WriteFloat32 writes a float32 value to the buffer.
func (*Buffer) WriteFloat64 ¶
WriteFloat64 writes a float64 value to the buffer.
func (*Buffer) WriteInt16 ¶
WriteInt16 writes an int16 value to the buffer.
func (*Buffer) WriteInt32 ¶
WriteInt32 writes an int32 value to the buffer.
func (*Buffer) WriteInt64 ¶
WriteInt64 writes an int64 value to the buffer.
func (*Buffer) WriteString ¶
WriteString writes the string's length as a uint16 followed by the string contents.
func (*Buffer) WriteUInt8 ¶
WriteUInt8 writes a uint8 value to the buffer.
func (*Buffer) WriteUInt16 ¶
WriteUInt16 writes a uint16 value to the buffer.
func (*Buffer) WriteUInt32 ¶
WriteUInt32 writes a uint32 value to the buffer.
func (*Buffer) WriteUInt64 ¶
WriteUInt64 writes a uint64 value to the buffer.