File: main.go

package info (click to toggle)
golang-github-tinylib-msgp 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,168 kB
  • sloc: makefile: 45
file content (27 lines) | stat: -rw-r--r-- 393 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
package main

//go:generate msgp

type Example struct {
	I int    `msg:"i"`
	S string `msg:"s"`
}

func main() {
	b := []byte{130, 161, 105, 1, 161, 115, 161, 50}

	var e2 Example
	extra, err := e2.UnmarshalMsg(b)
	if err != nil {
		panic(err)
	}
	if len(extra) != 0 {
		panic("unexpected extra")
	}

	if e2.I != 1 || e2.S != "2" {
		panic("not equal")
	}

	println("done, len(b):", len(b))
}