MCPcopy
hub / github.com/segmentio/kafka-go / peekRead

Function peekRead

read.go:13–23  ·  view source on GitHub ↗
(r *bufio.Reader, sz int, n int, f func([]byte))

Source from the content-addressed store, hash-verified

11var errShortRead = errors.New("not enough bytes available to load the response")
12
13func peekRead(r *bufio.Reader, sz int, n int, f func([]byte)) (int, error) {
14 if n > sz {
15 return sz, errShortRead
16 }
17 b, err := r.Peek(n)
18 if err != nil {
19 return sz, err
20 }
21 f(b)
22 return discardN(r, sz, n)
23}
24
25func readInt8(r *bufio.Reader, sz int, v *int8) (int, error) {
26 return peekRead(r, sz, 1, func(b []byte) { *v = makeInt8(b) })

Callers 5

readInt8Function · 0.85
readInt16Function · 0.85
readInt32Function · 0.85
readInt64Function · 0.85
readBoolFunction · 0.85

Calls 2

discardNFunction · 0.85
PeekMethod · 0.65

Tested by

no test coverage detected