NewBytes constructs a Bytes value from b. The returned value references b, it does not make a copy of the backing array. If b is nil, nil is returned to represent a null BYTES value in the kafka protocol.
(b []byte)
| 35 | // If b is nil, nil is returned to represent a null BYTES value in the kafka |
| 36 | // protocol. |
| 37 | func NewBytes(b []byte) Bytes { |
| 38 | if b == nil { |
| 39 | return nil |
| 40 | } |
| 41 | r := new(bytesReader) |
| 42 | r.Reset(b) |
| 43 | return r |
| 44 | } |
| 45 | |
| 46 | // ReadAll is similar to ioutil.ReadAll, but it takes advantage of knowing the |
| 47 | // length of b to minimize the memory footprint. |