msgpack

package
v2.781.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package msgpack provides MessagePack encoding helpers and adapters used by go-service.

This package integrates MessagePack encoding/decoding behind the go-service encoding abstraction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v any) ([]byte, error)

Marshal encodes v as MessagePack.

func Unmarshal

func Unmarshal(data []byte, v any) error

Unmarshal decodes one MessagePack value from data into v.

It uses Decode, so it rejects trailing encoded values or malformed trailing data.

Types

type Encoder

type Encoder struct{}

Encoder implements MessagePack encoding and decoding.

func NewEncoder

func NewEncoder() *Encoder

NewEncoder constructs a MessagePack encoder.

func (*Encoder) Decode

func (e *Encoder) Decode(r io.Reader, v any, opts ...codec.Option) error

Decode reads one MessagePack value from r and decodes it into v.

In most cases v should be a pointer to the destination value (for example *MyStruct). Decode rejects unknown destination fields unless github.com/alexfalkowski/go-service/v2/encoding/codec.WithDiscardUnknown is supplied. It also rejects trailing encoded values or malformed trailing data.

func (*Encoder) Encode

func (e *Encoder) Encode(w io.Writer, v any, _ ...codec.Option) error

Encode writes v to w as MessagePack. MessagePack has no required-field concept, so github.com/alexfalkowski/go-service/v2/encoding/codec.WithAllowPartial has no effect.

Jump to

Keyboard shortcuts

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