binary

package
v0.0.0-...-e0aed8b Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package binary extends Go standard library package encoding/binary to support arbitrary, variable-sized values. The Go standard library package encoding/binary provides encoding/decoding of fixed-size Go values or slices of same. This package extends support to arbitrary, variable-sized values by prefixing these values with their varint-encoded size, recursively. It expects the encoded type and decoded type to match exactly and makes no attempt to reconcile or check for any differences.

Index

Constants

This section is empty.

Variables

View Source
var (
	LittleEndian  = binary.LittleEndian
	BigEndian     = binary.BigEndian
	DefaultEndian = LittleEndian
)

Functions

func Marshal

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

func Unmarshal

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

Types

type Decoder

type Decoder struct {
	Order binary.ByteOrder
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode(v interface{}) (err error)

type Encoder

type Encoder struct {
	Order binary.ByteOrder
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func NewStrictEncoder

func NewStrictEncoder(w io.Writer) *Encoder

NewStrictEncoder creates an encoder similar to NewEncoder, however if this encoder attempts to encode a struct and the struct has no encodable fields an error is returned whereas the encoder returned from NewEncoder will simply not write anything to `w`.

func (*Encoder) Encode

func (b *Encoder) Encode(v interface{}) (err error)

Jump to

Keyboard shortcuts

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