MCPcopy Create free account
hub / github.com/segmentio/encoding / readVarint

Method readVarint

thrift/compact.go:204–227  ·  view source on GitHub ↗
(typ string, min, max int64)

Source from the content-addressed store, hash-verified

202}
203
204func (r *compactReader) readVarint(typ string, min, max int64) (int64, error) {
205 var br io.ByteReader
206
207 switch x := r.Reader().(type) {
208 case *bytes.Buffer:
209 br = x
210 case *bytes.Reader:
211 br = x
212 case *bufio.Reader:
213 br = x
214 case io.ByteReader:
215 br = x
216 default:
217 br = &r.binary
218 }
219
220 v, err := binary.ReadVarint(br)
221 if err == nil {
222 if v < min || v > max {
223 err = fmt.Errorf("%s varint out of range: %d not in [%d;%d]", typ, v, min, max)
224 }
225 }
226 return v, err
227}
228
229type compactWriter struct {
230 protocol *CompactProtocol

Callers 3

ReadInt16Method · 0.95
ReadInt32Method · 0.95
ReadInt64Method · 0.95

Calls 1

ReaderMethod · 0.95

Tested by

no test coverage detected