WriteExtensibleString sends the output of the given function, plus the given suffix, to w, together with a varint31 length prefix.
(w io.Writer, suffix []byte, f func(io.Writer) error)
| 187 | // WriteExtensibleString sends the output of the given function, plus |
| 188 | // the given suffix, to w, together with a varint31 length prefix. |
| 189 | func WriteExtensibleString(w io.Writer, suffix []byte, f func(io.Writer) error) (int, error) { |
| 190 | buf := bufpool.Get() |
| 191 | defer bufpool.Put(buf) |
| 192 | err := f(buf) |
| 193 | if err != nil { |
| 194 | return 0, err |
| 195 | } |
| 196 | if len(suffix) > 0 { |
| 197 | _, err := buf.Write(suffix) |
| 198 | if err != nil { |
| 199 | return 0, err |
| 200 | } |
| 201 | } |
| 202 | return WriteVarstr31(w, buf.Bytes()) |
| 203 | } |