gostruct

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 6 Imported by: 4

README

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 []interface{}) ([]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) ([]interface{}, error)

Unpack the byte slice (presumably packed by Pack(format, msg)) according to the given format. The result is a []interface{} 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 Endianess

type Endianess int
const (
	BIG_ENDIAN Endianess = iota
	LITTLE_ENDIAN
)

func (Endianess) ByteOrder

func (e Endianess) ByteOrder() binary.ByteOrder

Jump to

Keyboard shortcuts

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