Next returns a slice containing the next n bytes from the reader If there are fewer bytes than the given n, io.ErrUnexpectedEOF will be returned
(n int)
| 69 | // Next returns a slice containing the next n bytes from the reader |
| 70 | // If there are fewer bytes than the given n, io.ErrUnexpectedEOF will be returned |
| 71 | func (b *ByteBuffer) Next(n int) ([]byte, error) { |
| 72 | m := len(b.buf) - b.off |
| 73 | |
| 74 | if n > m { |
| 75 | return nil, io.ErrUnexpectedEOF |
| 76 | } |
| 77 | |
| 78 | data := b.buf[b.off : b.off+n] |
| 79 | b.off += n |
| 80 | |
| 81 | return data, nil |
| 82 | } |
| 83 | |
| 84 | // NextReturnsSafeSlice returns false since ByteBuffer might hold |
| 85 | // an array owned by some other systems. |
no outgoing calls
no test coverage detected