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.
()
| 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. |
| 122 | func 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. |
nothing calls this directly
no test coverage detected
searching dependent graphs…