MCPcopy Index your code
hub / github.com/tinylib/msgp / ExampleReadArrayBytes

Function ExampleReadArrayBytes

msgp/iter_test.go:122–140  ·  view source on GitHub ↗

Example: reading an array of strings from a byte slice using ReadArrayBytes. It prints each element and then checks for a final error from the returned closure.

()

Source from the content-addressed store, hash-verified

120// Example: reading an array of strings from a byte slice using ReadArrayBytes.
121// It prints each element and then checks for a final error from the returned closure.
122func ExampleReadArrayBytes() {
123 var b []byte
124 // Append ["x","y","z"] using AppendArray
125 b = AppendArray(b, []string{"x", "y", "z"}, AppendString)
126
127 seq, finish := ReadArrayBytes(b, ReadStringBytes)
128 seq(func(s string) bool {
129 fmt.Println(s)
130 return true
131 })
132 if _, err := finish(); err != nil {
133 fmt.Println("err:", err)
134 }
135
136 // Output:
137 // x
138 // y
139 // z
140}
141
142// Example: reading a map[string]float64 from a byte slice using ReadMapBytes.
143// It prints key=value pairs and then checks the remaining bytes/error from the returned closure.

Callers

nothing calls this directly

Calls 2

AppendArrayFunction · 0.85
ReadArrayBytesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…