std/encoding/binary
import "github.com/eugenioenko/goalchemy/std/encoding/binary"Package binary translates between unsigned integers and byte sequences, and encodes varints.
const ( MaxVarintLen16 = 3 MaxVarintLen32 = 5 MaxVarintLen64 = 10)Maximum encoded lengths of varints.
var BigEndian bigEndianBigEndian is the big-endian ByteOrder and AppendByteOrder.
var LittleEndian littleEndianLittleEndian is the little-endian ByteOrder and AppendByteOrder.
AppendUvarint
Section titled “AppendUvarint”func AppendUvarint(buf []byte, x uint64) []byteAppendUvarint appends the varint encoding of x to buf.
AppendVarint
Section titled “AppendVarint”func AppendVarint(buf []byte, x int64) []byteAppendVarint appends the zig-zag varint encoding of x to buf.
PutUvarint
Section titled “PutUvarint”func PutUvarint(buf []byte, x uint64) intPutUvarint encodes x into buf, which must be large enough, and returns the number of bytes written.
PutVarint
Section titled “PutVarint”func PutVarint(buf []byte, x int64) intPutVarint encodes x with zig-zag varint encoding into buf.
Uvarint
Section titled “Uvarint”func Uvarint(buf []byte) (uint64, int)Uvarint decodes a varint from buf and returns the value and the number of bytes read. n == 0 means buf is too short; n < 0 means the value overflows 64 bits and -n bytes were read.
Varint
Section titled “Varint”func Varint(buf []byte) (int64, int)Varint decodes a zig-zag varint from buf like Uvarint.
type AppendByteOrder
Section titled “type AppendByteOrder”type AppendByteOrder interface { AppendUint16([]byte, uint16) []byte AppendUint32([]byte, uint32) []byte AppendUint64([]byte, uint64) []byte String() string}AppendByteOrder appends unsigned integers in a byte order.
type ByteOrder
Section titled “type ByteOrder”type ByteOrder interface { Uint16([]byte) uint16 Uint32([]byte) uint32 Uint64([]byte) uint64 PutUint16([]byte, uint16) PutUint32([]byte, uint32) PutUint64([]byte, uint64) String() string}ByteOrder reads and writes unsigned integers in a byte order.