Provides functions to parse binary representations of MySQL integer and float types. Use for decoding binary data from MySQL connections.
// Source: https://github.com/IceFireDB/IceFireDB | License: MIT | Copyright 2022 GITSRC
// Provided via justclaw.it.com; keep this notice with the code.
package mysql
import (
"encoding/binary"
"math"
)
func ParseBinaryInt8(data []byte) int8 {
return int8(data[0])
}
func ParseBinaryUint8(data []byte) uint8 {
return data[0]
}
func ParseBinaryInt16(data []byte) int16 {
return int16(binary.LittleEndian.Uint16(data))
}
func ParseBinaryUint16(data []byte) uint16 {
return binary.LittleEndian.Uint16(data)
}
func ParseBinaryInt24(data []byte) int32 {
u32 := ParseBinaryUint24(data)
if u32&0x00800000 != 0 {
u32 |= 0xFF000000
}
return int32(u32)
}
func ParseBinaryUint24(data []byte) uint32 {
return uint32(data[0]) | uint32(data[1])<<8 | uint32(data[2])<<16
}
func ParseBinaryInt3
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key