File: README.md

package info (click to toggle)
golang-github-ugorji-go-msgpack 0.0~git20130605.792643-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 144 kB
  • ctags: 172
  • sloc: python: 71; makefile: 4
file content (62 lines) | stat: -rw-r--r-- 2,210 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# MsgPack library for Go (DEPRECATED)

> DEPRECATED as of May 29, 2013. Please use github.com/ugorji/go/codec  
> which is significantly faster, cleaner, more correct and more complete.  
> See [https://github.com/ugorji/go/tree/master/codec#readme]  
> 
> A complete redesign was done which accomodates multiple codec formats.
> It thus became necessary to create a new repository with a different name. 
> 
> I hope to retire this repository anytime from July 1, 2013.
> 
> A log message will be printed out at runtime encouraging users to upgrade.

## About go-msgpack

Implements:
>  [http://wiki.msgpack.org/display/MSGPACK/Format+specification]

To install:
>  go get github.com/ugorji/go-msgpack

It provides features similar to encoding packages in the standard library (ie json, xml, gob, etc).

Supports:
  * Standard Marshal/Unmarshal interface.
  * Support for all exported fields (including anonymous fields)
  * Standard field renaming via tags
  * Encoding from any value (struct, slice, map, primitives, pointers, interface{}, etc)
  * Decoding into pointer to any non-nil value (struct, slice, map, int, float32, bool, string, etc)
  * Decoding into a nil interface{} 
  * Handles time.Time transparently (stores time as 2 element array: seconds since epoch and nanosecond offset)
  * Provides a Server and Client Codec so msgpack can be used as communication protocol for net/rpc.
    * Also includes an option for msgpack-rpc: http://wiki.msgpack.org/display/MSGPACK/RPC+specification

API docs: http://godoc.org/github.com/ugorji/go-msgpack

Usage
-----

<pre>

    dec = msgpack.NewDecoder(r, nil)  
    err = dec.Decode(&v)  
    
    enc = msgpack.NewEncoder(w)  
    err = enc.Encode(v)  
    
    //methods below are convenience methods over functions above.  
    data, err = msgpack.Marshal(v)  
    err = msgpack.Unmarshal(data, &v, nil)  
    
    //RPC Server
    conn, err := listener.Accept()
    rpcCodec := msgpack.NewRPCServerCodec(conn, nil)
    rpc.ServeCodec(rpcCodec)

    //RPC Communication (client side)
    conn, err = net.Dial("tcp", "localhost:5555")  
    rpcCodec := msgpack.NewRPCClientCodec(conn, nil)  
    client := rpc.NewClientWithCodec(rpcCodec)  

</pre>