Documentation ¶
Overview ¶
Package gbinary provides useful API for handling binary/bytes data.
Note that package gbinary encodes the data using LittleEndian in default.
Index ¶
- func BeDecode(b []byte, values ...interface{}) error
- func BeDecodeToBool(b []byte) bool
- func BeDecodeToFloat32(b []byte) float32
- func BeDecodeToFloat64(b []byte) float64
- func BeDecodeToInt(b []byte) int
- func BeDecodeToInt16(b []byte) int16
- func BeDecodeToInt32(b []byte) int32
- func BeDecodeToInt64(b []byte) int64
- func BeDecodeToInt8(b []byte) int8
- func BeDecodeToString(b []byte) string
- func BeDecodeToUint(b []byte) uint
- func BeDecodeToUint16(b []byte) uint16
- func BeDecodeToUint32(b []byte) uint32
- func BeDecodeToUint64(b []byte) uint64
- func BeDecodeToUint8(b []byte) uint8
- func BeEncode(values ...interface{}) []byte
- func BeEncodeBool(b bool) []byte
- func BeEncodeByLength(length int, values ...interface{}) []byte
- func BeEncodeFloat32(f float32) []byte
- func BeEncodeFloat64(f float64) []byte
- func BeEncodeInt(i int) []byte
- func BeEncodeInt16(i int16) []byte
- func BeEncodeInt32(i int32) []byte
- func BeEncodeInt64(i int64) []byte
- func BeEncodeInt8(i int8) []byte
- func BeEncodeString(s string) []byte
- func BeEncodeUint(i uint) []byte
- func BeEncodeUint16(i uint16) []byte
- func BeEncodeUint32(i uint32) []byte
- func BeEncodeUint64(i uint64) []byte
- func BeEncodeUint8(i uint8) []byte
- func BeFillUpSize(b []byte, l int) []byte
- func Decode(b []byte, values ...interface{}) error
- func DecodeBits(bits []Bit) int
- func DecodeBitsToUint(bits []Bit) uint
- func DecodeToBool(b []byte) bool
- func DecodeToFloat32(b []byte) float32
- func DecodeToFloat64(b []byte) float64
- func DecodeToInt(b []byte) int
- func DecodeToInt16(b []byte) int16
- func DecodeToInt32(b []byte) int32
- func DecodeToInt64(b []byte) int64
- func DecodeToInt8(b []byte) int8
- func DecodeToString(b []byte) string
- func DecodeToUint(b []byte) uint
- func DecodeToUint16(b []byte) uint16
- func DecodeToUint32(b []byte) uint32
- func DecodeToUint64(b []byte) uint64
- func DecodeToUint8(b []byte) uint8
- func Encode(values ...interface{}) []byte
- func EncodeBitsToBytes(bits []Bit) []byte
- func EncodeBool(b bool) []byte
- func EncodeByLength(length int, values ...interface{}) []byte
- func EncodeFloat32(f float32) []byte
- func EncodeFloat64(f float64) []byte
- func EncodeInt(i int) []byte
- func EncodeInt16(i int16) []byte
- func EncodeInt32(i int32) []byte
- func EncodeInt64(i int64) []byte
- func EncodeInt8(i int8) []byte
- func EncodeString(s string) []byte
- func EncodeUint(i uint) []byte
- func EncodeUint16(i uint16) []byte
- func EncodeUint32(i uint32) []byte
- func EncodeUint64(i uint64) []byte
- func EncodeUint8(i uint8) []byte
- func LeDecode(b []byte, values ...interface{}) error
- func LeDecodeToBool(b []byte) bool
- func LeDecodeToFloat32(b []byte) float32
- func LeDecodeToFloat64(b []byte) float64
- func LeDecodeToInt(b []byte) int
- func LeDecodeToInt16(b []byte) int16
- func LeDecodeToInt32(b []byte) int32
- func LeDecodeToInt64(b []byte) int64
- func LeDecodeToInt8(b []byte) int8
- func LeDecodeToString(b []byte) string
- func LeDecodeToUint(b []byte) uint
- func LeDecodeToUint16(b []byte) uint16
- func LeDecodeToUint32(b []byte) uint32
- func LeDecodeToUint64(b []byte) uint64
- func LeDecodeToUint8(b []byte) uint8
- func LeEncode(values ...interface{}) []byte
- func LeEncodeBool(b bool) []byte
- func LeEncodeByLength(length int, values ...interface{}) []byte
- func LeEncodeFloat32(f float32) []byte
- func LeEncodeFloat64(f float64) []byte
- func LeEncodeInt(i int) []byte
- func LeEncodeInt16(i int16) []byte
- func LeEncodeInt32(i int32) []byte
- func LeEncodeInt64(i int64) []byte
- func LeEncodeInt8(i int8) []byte
- func LeEncodeString(s string) []byte
- func LeEncodeUint(i uint) []byte
- func LeEncodeUint16(i uint16) []byte
- func LeEncodeUint32(i uint32) []byte
- func LeEncodeUint64(i uint64) []byte
- func LeEncodeUint8(i uint8) []byte
- func LeFillUpSize(b []byte, l int) []byte
- type Bit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BeDecodeToBool ¶
func BeDecodeToFloat32 ¶
func BeDecodeToFloat64 ¶
func BeDecodeToInt ¶
func BeDecodeToInt16 ¶
func BeDecodeToInt32 ¶
func BeDecodeToInt64 ¶
func BeDecodeToInt8 ¶
func BeDecodeToString ¶
func BeDecodeToUint ¶
func BeDecodeToUint16 ¶
func BeDecodeToUint32 ¶
func BeDecodeToUint64 ¶
func BeDecodeToUint8 ¶
func BeEncode ¶
func BeEncode(values ...interface{}) []byte
BeEncode encodes one or multiple `values` into bytes using BigEndian. It uses type asserting checking the type of each value of `values` and internally calls corresponding converting function do the bytes converting.
It supports common variable type asserting, and finally it uses fmt.Sprintf converting value to string and then to bytes.
func BeEncodeBool ¶
func BeEncodeByLength ¶
func BeEncodeFloat32 ¶
func BeEncodeFloat64 ¶
func BeEncodeInt ¶
func BeEncodeInt16 ¶
func BeEncodeInt32 ¶
func BeEncodeInt64 ¶
func BeEncodeInt8 ¶
func BeEncodeString ¶
func BeEncodeUint ¶
func BeEncodeUint16 ¶
func BeEncodeUint32 ¶
func BeEncodeUint64 ¶
func BeEncodeUint8 ¶
func BeFillUpSize ¶
BeFillUpSize fills up the bytes `b` to given length `l` using big BigEndian.
Note that it creates a new bytes slice by copying the original one to avoid changing the original parameter bytes.
func DecodeBits ¶
DecodeBits .does decode bits to int Resolve to int
func DecodeToBool ¶
func DecodeToFloat32 ¶
func DecodeToFloat64 ¶
func DecodeToInt ¶
func DecodeToInt16 ¶
func DecodeToInt32 ¶
func DecodeToInt64 ¶
func DecodeToInt8 ¶
func DecodeToString ¶
func DecodeToUint ¶
func DecodeToUint16 ¶
func DecodeToUint32 ¶
func DecodeToUint64 ¶
func DecodeToUint8 ¶
func EncodeBitsToBytes ¶
EncodeBitsToBytes . does encode bits to bytes Convert bits to [] byte, encode from left to right, and add less than 1 byte from 0 to the end.
func EncodeBool ¶
func EncodeByLength ¶
func EncodeFloat32 ¶
func EncodeFloat64 ¶
func EncodeInt16 ¶
func EncodeInt32 ¶
func EncodeInt64 ¶
func EncodeInt8 ¶
func EncodeString ¶
func EncodeUint ¶
func EncodeUint16 ¶
func EncodeUint32 ¶
func EncodeUint64 ¶
func EncodeUint8 ¶
func LeDecodeToBool ¶
func LeDecodeToFloat32 ¶
func LeDecodeToFloat64 ¶
func LeDecodeToInt ¶
func LeDecodeToInt16 ¶
func LeDecodeToInt32 ¶
func LeDecodeToInt64 ¶
func LeDecodeToInt8 ¶
func LeDecodeToString ¶
func LeDecodeToUint ¶
func LeDecodeToUint16 ¶
func LeDecodeToUint32 ¶
func LeDecodeToUint64 ¶
func LeDecodeToUint8 ¶
func LeEncode ¶
func LeEncode(values ...interface{}) []byte
LeEncode encodes one or multiple `values` into bytes using LittleEndian. It uses type asserting checking the type of each value of `values` and internally calls corresponding converting function do the bytes converting.
It supports common variable type asserting, and finally it uses fmt.Sprintf converting value to string and then to bytes.
func LeEncodeBool ¶
func LeEncodeByLength ¶
func LeEncodeFloat32 ¶
func LeEncodeFloat64 ¶
func LeEncodeInt ¶
func LeEncodeInt16 ¶
func LeEncodeInt32 ¶
func LeEncodeInt64 ¶
func LeEncodeInt8 ¶
func LeEncodeString ¶
func LeEncodeUint ¶
func LeEncodeUint16 ¶
func LeEncodeUint32 ¶
func LeEncodeUint64 ¶
func LeEncodeUint8 ¶
func LeFillUpSize ¶
LeFillUpSize fills up the bytes `b` to given length `l` using LittleEndian.
Note that it creates a new bytes slice by copying the original one to avoid changing the original parameter bytes.
Types ¶
type Bit ¶
type Bit int8
Bit Binary bit (0 | 1)
func DecodeBytesToBits ¶
DecodeBytesToBits .Parsing [] byte into character array [] uint8
func EncodeBits ¶
EncodeBits does encode bits return bits Default coding