binary

package
v0.0.0-...-599cc13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package binary replaces the encoding/binary package in the standard library for little endian encoding using generics.

Index

Constants

This section is empty.

Variables

Enc is the little-endian binary encoder. Do not change this.

Functions

func Get

func Get[T constraints.Integer](b []byte) T

Get gets any Uint size from a []byte slice.

func GetBuffer

func GetBuffer[T constraints.Integer](r io.Reader) (T, error)

GetBuffer reads from an io.Reader and decodes into the specified integer type.

func GetBufferInt8

func GetBufferInt8(r io.Reader) (int8, error)

GetBufferInt8 reads an int8 from an io.Reader.

func GetBufferInt16

func GetBufferInt16(r io.Reader) (int16, error)

GetBufferInt16 reads an int16 from an io.Reader (little-endian).

func GetBufferInt32

func GetBufferInt32(r io.Reader) (int32, error)

GetBufferInt32 reads an int32 from an io.Reader (little-endian).

func GetBufferInt64

func GetBufferInt64(r io.Reader) (int64, error)

GetBufferInt64 reads an int64 from an io.Reader (little-endian).

func GetBufferUint8

func GetBufferUint8(r io.Reader) (uint8, error)

GetBufferUint8 reads a uint8 from an io.Reader.

func GetBufferUint16

func GetBufferUint16(r io.Reader) (uint16, error)

GetBufferUint16 reads a uint16 from an io.Reader (little-endian).

func GetBufferUint32

func GetBufferUint32(r io.Reader) (uint32, error)

GetBufferUint32 reads a uint32 from an io.Reader (little-endian).

func GetBufferUint64

func GetBufferUint64(r io.Reader) (uint64, error)

GetBufferUint64 reads a uint64 from an io.Reader (little-endian).

func GetInt8

func GetInt8(b []byte) int8

GetInt8 reads an int8 from a byte slice.

func GetInt16

func GetInt16(b []byte) int16

GetInt16 reads an int16 from a byte slice (little-endian).

func GetInt32

func GetInt32(b []byte) int32

GetInt32 reads an int32 from a byte slice (little-endian).

func GetInt64

func GetInt64(b []byte) int64

GetInt64 reads an int64 from a byte slice (little-endian).

func GetUint8

func GetUint8(b []byte) uint8

GetUint8 reads a uint8 from a byte slice.

func GetUint16

func GetUint16(b []byte) uint16

GetUint16 reads a uint16 from a byte slice (little-endian).

func GetUint32

func GetUint32(b []byte) uint32

GetUint32 reads a uint32 from a byte slice (little-endian).

func GetUint64

func GetUint64(b []byte) uint64

GetUint64 reads a uint64 from a byte slice (little-endian).

func Put

func Put[T constraints.Integer](b []byte, v T)

Put puts any Uint size into a []byte slice.

func PutBuffer

func PutBuffer[T constraints.Integer](buff io.Writer, v T) error

PutBuffer encodes an integer into the passed Buffer.

func PutBufferInt8

func PutBufferInt8(w io.Writer, v int8) error

PutBufferInt8 writes an int8 to an io.Writer.

func PutBufferInt16

func PutBufferInt16(w io.Writer, v int16) error

PutBufferInt16 writes an int16 to an io.Writer (little-endian).

func PutBufferInt32

func PutBufferInt32(w io.Writer, v int32) error

PutBufferInt32 writes an int32 to an io.Writer (little-endian).

func PutBufferInt64

func PutBufferInt64(w io.Writer, v int64) error

PutBufferInt64 writes an int64 to an io.Writer (little-endian).

func PutBufferUint8

func PutBufferUint8(w io.Writer, v uint8) error

PutBufferUint8 writes a uint8 to an io.Writer.

func PutBufferUint16

func PutBufferUint16(w io.Writer, v uint16) error

PutBufferUint16 writes a uint16 to an io.Writer (little-endian).

func PutBufferUint32

func PutBufferUint32(w io.Writer, v uint32) error

PutBufferUint32 writes a uint32 to an io.Writer (little-endian).

func PutBufferUint64

func PutBufferUint64(w io.Writer, v uint64) error

PutBufferUint64 writes a uint64 to an io.Writer (little-endian).

func PutInt8

func PutInt8(b []byte, v int8)

PutInt8 writes an int8 to a byte slice.

func PutInt16

func PutInt16(b []byte, v int16)

PutInt16 writes an int16 to a byte slice (little-endian).

func PutInt32

func PutInt32(b []byte, v int32)

PutInt32 writes an int32 to a byte slice (little-endian).

func PutInt64

func PutInt64(b []byte, v int64)

PutInt64 writes an int64 to a byte slice (little-endian).

func PutUint8

func PutUint8(b []byte, v uint8)

PutUint8 writes a uint8 to a byte slice.

func PutUint16

func PutUint16(b []byte, v uint16)

PutUint16 writes a uint16 to a byte slice (little-endian).

func PutUint32

func PutUint32(b []byte, v uint32)

PutUint32 writes a uint32 to a byte slice (little-endian).

func PutUint64

func PutUint64(b []byte, v uint64)

PutUint64 writes a uint64 to a byte slice (little-endian).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL