Documentation ¶
Index ¶
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Cur() []byte
- func (b *Buffer) More() bool
- func (b *Buffer) Read(n int) []byte
- func (b *Buffer) ReadDecimal(precision, decimals int) mysql.Decimal
- func (b *Buffer) ReadFloat32() float32
- func (b *Buffer) ReadFloat64() float64
- func (b *Buffer) ReadStringEOF() []byte
- func (b *Buffer) ReadStringLenEnc() (str []byte, size int)
- func (b *Buffer) ReadStringNullTerm() []byte
- func (b *Buffer) ReadStringVarEnc(n int) []byte
- func (b *Buffer) ReadStringVarLen(n int) []byte
- func (b *Buffer) ReadUint16() uint16
- func (b *Buffer) ReadUint24() uint32
- func (b *Buffer) ReadUint32() uint32
- func (b *Buffer) ReadUint48() uint64
- func (b *Buffer) ReadUint64() uint64
- func (b *Buffer) ReadUint8() uint8
- func (b *Buffer) ReadUintLenEnc() (val uint64, isNull bool, size int)
- func (b *Buffer) ReadVarLen64(n int) uint64
- func (b *Buffer) Skip(n int)
- func (b *Buffer) WriteByte(v byte)
- func (b *Buffer) WriteStringEOF(s string)
- func (b *Buffer) WriteStringLenEnc(s string)
- func (b *Buffer) WriteUint16(v uint16)
- func (b *Buffer) WriteUint32(v uint32)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a simple wrapper over a slice of bytes with a cursor. It allows for easy command building and results parsing.
func New ¶
New creates a new buffer from a given slice of bytes and sets the cursor to the beginning.
func NewCommandBuffer ¶
NewCommandBuffer pre-allocates a buffer of a given size and reserves 4 bytes at the beginning for the driver, these would be used to set command length and sequence number.
func (*Buffer) ReadDecimal ¶
ReadDecimal decodes a decimal value from the buffer anf then advances cursor accordingly.
func (*Buffer) ReadFloat32 ¶
ReadFloat32 reads a float32 and advances cursor by 4 bytes.
func (*Buffer) ReadFloat64 ¶
ReadFloat64 reads a float64 and advances cursor by 8 bytes.
func (*Buffer) ReadStringEOF ¶
ReadStringEOF reads remaining contents of the buffer as a new string.
func (*Buffer) ReadStringLenEnc ¶
ReadStringLenEnc reads a length-encoded string and advances cursor accordingly.
func (*Buffer) ReadStringNullTerm ¶
ReadStringNullTerm reads a NULL-terminated string and advances cursor by its length plus 1 extra byte.
func (*Buffer) ReadStringVarEnc ¶
ReadStringVarEnc reads a variable-length length of the string and the string itself, then advances cursor by the same number of bytes.
func (*Buffer) ReadStringVarLen ¶
ReadStringVarLen reads a variable-length string and advances cursor by the same number of bytes.
func (*Buffer) ReadUint16 ¶
ReadUint16 reads a uint16 and advances cursor by 2 bytes.
func (*Buffer) ReadUint24 ¶
ReadUint24 reads a 3-byte integer as uint32 and advances cursor by 3 bytes.
func (*Buffer) ReadUint32 ¶
ReadUint32 reads a uint32 and advances cursor by 4 bytes.
func (*Buffer) ReadUint48 ¶
ReadUint48 reads a 6-byte integer as uint64 and advances cursor by 6 bytes.
func (*Buffer) ReadUint64 ¶
ReadUint64 reads a uint64 and advances cursor by 8 bytes.
func (*Buffer) ReadUintLenEnc ¶
ReadUintLenEnc reads a length-encoded integer and advances cursor accordingly.
func (*Buffer) ReadVarLen64 ¶
ReadVarLen64 reads a number encoded in given size of bytes and advances cursor accordingly.
func (*Buffer) WriteStringEOF ¶
WriteStringEOF writes given string to the buffer and advances cursor by its length.
func (*Buffer) WriteStringLenEnc ¶
WriteStringLenEnc writes a length-encoded string to the buffer and advances cursor accordingly.
func (*Buffer) WriteUint16 ¶
WriteUint16 writes given uint16 value to the buffer and advances cursor by 2.
func (*Buffer) WriteUint32 ¶
WriteUint32 writes given uint32 value to the buffer and advances cursor by 4.