binary

package module
v0.0.0-...-0829b1e Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 1 Imported by: 0

README

Encoding/Binary

Binary Serializer for Go

Dependency:

github.com/kelindar/binary

Encode/Decode arbitrary golang data structures of variable size. This package extends support to arbitrary, variable-sized values by prefixing these values with their varint-encoded size, recursively. This was originally inspired by Alec Thomas's binary package, but I've reworked the serialization format and improved the performance and size.

Usage

Import the package

import (
    ...
    "github.com/paulusrobin/leaf-utilities/encoding/binary"
    ...
)

To serialize a message, simply Marshal:

v := &message{
    Name:      "Roman",
    Timestamp: 1242345235,
    Payload:   []byte("hi"),
    Ssid:      []uint32{1, 2, 3},
}
encoded, err := binary.Marshal(v)

To deserialize, Unmarshal:

var v message
err := binary.Unmarshal(encoded, &v)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v interface{}) (data []byte, err error)

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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