msgpack

package module
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: MIT Imports: 3 Imported by: 31

README

MessagePack for Golang

GoDoc Build Status Coverage Status Releases

Usage

Installation
go get -u github.com/shamaton/msgpack
How to use
use simply
package main;

import (
  "github.com/shamaton/msgpack"
)

func main() {
	type Struct struct {
		String string
	}
	v := Struct{String: "msgpack"}

	d, err := msgpack.Encode(v)
	if err != nil {
		panic(err)
	}
	r := Struct{}
	err = msgpack.Decode(d, &r)
	if err != nil {
		panic(err)
	}
}

License

This library is under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StructAsArray = false

StructAsArray is encoding option. If this option sets true, default encoding sets to array-format.

Functions

func AddExtCoder

func AddExtCoder(e ext.Encoder, d ext.Decoder)

AddExtCoder adds encoders for extension types.

func Decode

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

Decode analyzes the MessagePack-encoded data and stores the result into the pointer of v.

func DecodeStructAsArray

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

DecodeStructAsArray decodes data that is encoded as array format. This is the same thing that StructAsArray sets true.

func DecodeStructAsMap

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

DecodeStructAsMap decodes data that is encoded as map format. This is the same thing that StructAsArray sets false.

func Encode

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

Encode returns the MessagePack-encoded byte array of v.

func EncodeStructAsArray

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

EncodeStructAsArray encodes data as array format. This is the same thing that StructAsArray sets true.

func EncodeStructAsMap

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

EncodeStructAsMap encodes data as map format. This is the same thing that StructAsArray sets false.

func RemoveExtCoder

func RemoveExtCoder(e ext.Encoder, d ext.Decoder)

RemoveExtCoder removes encoders for extension types.

Types

This section is empty.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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