binarypack

package
v0.0.0-...-f64af9c Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcSize

func CalcSize(format []string) (int, error)

Return the size of the struct (and hence of the byte slice) corresponding to the given format.

func Pack

func Pack(format []string, msg []any, order binary.ByteOrder) ([]byte, error)

Return a byte slice containing the values of msg slice packed according to the given format. The items of msg slice must match the values required by the format exactly.

func UnPack

func UnPack(format []string, msg []byte, order binary.ByteOrder) ([]any, error)

Unpack the byte slice (presumably packed by Pack(format, msg)) according to the given format. The result is a []any slice even if it contains exactly one item. The byte slice must contain not less the amount of data required by the format (len(msg) must more or equal CalcSize(format)).

Types

type Integer

type Integer interface {
	int | int16 | int32 | int64 | uint16 | uint32 | uint64
}

Jump to

Keyboard shortcuts

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