var data = []byte{ 0x82, // begin map (2 pairs) 0xa4, 'n', 'a', 'm', 'e', 0xa5, 'A', 'l', 'i', 'c', 'e', 0xa3, 'a', 'g', 'e', // begin string "age" 0x18, 0x1e, // unsigned integer 30 0x00, // end map } r := msgp.NewReader(bytes.NewReader(data)) name, err := r.ReadString() age, err := r.ReadUint()
var data = []byte{ 0x92, // begin array (2 elements) 0x01, // integer 1 0x02, // integer 2 0x00, // end array } r := msgp.NewReader(bytes.NewReader(data)) arrayLen, err := r.ReadArrayHeader() for i := 0; i < arrayLen; i++ { elem, err := r.ReadInt() }In this example, we are parsing a MessagePack data stream that contains an array with two integer values. We create a new Reader using the `bytes.NewReader()` function and read the length of the array using the `ReadArrayHeader()` method of the Reader. We then loop over the array and read each element using the `ReadInt()` method of the Reader. Overall, the go github.com.tinylib.msgp.msgp Reader package is a versatile and efficient library for working with the MessagePack serialization format in the Go language.