Giter Site home page Giter Site logo

huoyan108 / msgpack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vmihailenco/msgpack

0.0 2.0 0.0 271 KB

MessagePack encoding for Golang

Home Page: http://godoc.org/gopkg.in/vmihailenco/msgpack.v2#pkg-examples

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.05% Go 99.95%

msgpack's Introduction

MessagePack encoding for Golang Build Status

Supports:

  • Primitives, arrays, maps, structs, time.Time and interface{}.
  • Appengine *datastore.Key and datastore.Cursor.
  • CustomEncoder/CustomDecoder interfaces for custom encoding.
  • Extensions to encode type information.
  • Fields renaming, e.g. msgpack:"my_field_name".
  • Structs inlining, e.g. msgpack:",inline".
  • Omitempty flag, e.g. msgpack:",omitempty".

API docs: http://godoc.org/gopkg.in/vmihailenco/msgpack.v2. Examples: http://godoc.org/gopkg.in/vmihailenco/msgpack.v2#pkg-examples.

Installation

Install:

go get gopkg.in/vmihailenco/msgpack.v2

Quickstart

func ExampleMarshal() {
	b, err := msgpack.Marshal(true)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", b)
	// Output:

	var out bool
	err = msgpack.Unmarshal([]byte{0xc3}, &out)
	if err != nil {
		panic(err)
	}
	fmt.Println(out)
	// Output: []byte{0xc3}
	// true
}

Benchmark

BenchmarkStructVmihailencoMsgpack-4	  200000	     11430 ns/op	    3136 B/op	      26 allocs/op
BenchmarkStructUgorjiGoMsgpack-4   	  100000	     14731 ns/op	    3616 B/op	      70 allocs/op
BenchmarkStructUgorjiGoCodec-4     	  100000	     19947 ns/op	    7362 B/op	      29 allocs/op
BenchmarkStructJSON-4              	   30000	     56042 ns/op	    7896 B/op	      26 allocs/op
BenchmarkStructGOB-4               	   20000	     76835 ns/op	   14665 B/op	     278 allocs/op

Howto

Please go through examples to get an idea how to use this package.

msgpack's People

Contributors

anmic avatar dim avatar gyf19 avatar myitcv avatar rjeczalik avatar vmihailenco avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.