binaryext

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 1 Imported by: 0

README

go-binaryext

CircleCI GoDoc

Package binaryext provides functions that supplement the golang encoding/binary library. In particular, while encoding/binary provides varint encoding, binaryext provides binary encoding of straight integers, providing twice the efficiency since all 8 bits in a byte are available for use (rather than 7 with varint).

Documentation

Overview

Package binaryext provides functions that supplement the golang encoding/binary library. In particular, while encoding/binary provides varint encoding, binaryext provides binary encoding of straight integers, providing twice the efficiency since all 8 bits in a byte are available for use (rather than 7 with varint).

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOverflow occurs when more bytes are provided than can
	// be handled by the receiving type.
	ErrOverflow = errors.NewInvalidArgumentError("Byte count exceeds expectation.")

	// ErrEmpty occurs when an empty slice of bytes is received
	// for writing to a type.
	ErrEmpty = errors.NewInvalidArgumentError("No bytes provided.")
)

Functions

func Int16

func Int16(buf []byte) (int16, error)

Int16 decodes a int16 from []byte

func Int32

func Int32(buf []byte) (int32, error)

Int32 decodes a int32 from []byte

func Int64

func Int64(buf []byte) (int64, error)

Int64 decodes a int64 from []byte

func Int8

func Int8(buf []byte) (int8, error)

Int8 decodes a int8 from []byte

func PutInt16

func PutInt16(x int16) []byte

PutInt16 encodes a int16 to []byte.

func PutInt32

func PutInt32(x int32) []byte

PutInt32 encodes a int32 to []byte.

func PutInt64

func PutInt64(x int64) []byte

PutInt64 encodes a int64 to []byte.

func PutInt8

func PutInt8(x int8) []byte

PutInt8 encodes a int8 to []byte.

func PutUint16

func PutUint16(x uint16) []byte

PutUint16 encodes a uint16 to []byte.

func PutUint32

func PutUint32(x uint32) []byte

PutUint32 encodes a uint32 to []byte.

func PutUint64

func PutUint64(x uint64) []byte

PutUint64 encodes a uint64 to []byte.

func PutUint8

func PutUint8(x uint8) []byte

PutUint8 encodes a uint8 to []byte.

func Uint16

func Uint16(buf []byte) (uint16, error)

Uint16 decodes a uint16 from []byte

func Uint32

func Uint32(buf []byte) (uint32, error)

Uint32 decodes a uint32 from []byte

func Uint64

func Uint64(buf []byte) (uint64, error)

Uint64 decodes a uint64 from []byte

func Uint8

func Uint8(buf []byte) (uint8, error)

Uint8 decodes a uint8 from []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

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