Ejemplo n.º 1
0
func Example_mapStringInterface() {
	in := map[string]interface{}{"foo": 1, "hello": "world"}
	b, err := msgpack.Marshal(in)
	_ = err

	var out map[string]interface{}
	err = msgpack.Unmarshal(b, &out)
	fmt.Printf("%v %#v\n", err, out)
	// Output: <nil> map[string]interface {}{"foo":1, "hello":"world"}
}
Ejemplo n.º 2
0
func (t *MsgpackTest) BenchmarkStructManual(c *C) {
	in := t.structForBenchmark2()
	out := &benchmarkStruct2{}
	for i := 0; i < c.N; i++ {
		b, err := msgpack.Marshal(in)
		if err != nil {
			panic(err)
		}
		err = msgpack.Unmarshal(b, out)
		if err != nil {
			panic(err)
		}
	}
}
Ejemplo n.º 3
0
func ExampleMarshal() {
	b, err := msgpack.Marshal(true)
	fmt.Printf("%v %#v\n", err, b)
	// Output: <nil> []byte{0xc3}
}