MCPcopy Index your code
hub / github.com/vmihailenco/msgpack / ExampleEncoder_UseArrayEncodedStructs

Function ExampleEncoder_UseArrayEncodedStructs

example_test.go:120–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

118}
119
120func ExampleEncoder_UseArrayEncodedStructs() {
121 type Item struct {
122 Foo string
123 Bar string
124 }
125
126 var buf bytes.Buffer
127 enc := msgpack.NewEncoder(&buf)
128 enc.UseArrayEncodedStructs(true)
129
130 err := enc.Encode(&Item{Foo: "foo", Bar: "bar"})
131 if err != nil {
132 panic(err)
133 }
134
135 dec := msgpack.NewDecoder(&buf)
136 v, err := dec.DecodeInterface()
137 if err != nil {
138 panic(err)
139 }
140 fmt.Println(v)
141 // Output: [foo bar]
142}
143
144func ExampleMarshal_asArray() {
145 type Item struct {

Callers

nothing calls this directly

Calls 3

EncodeMethod · 0.95
DecodeInterfaceMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…