These functions provide variable length encoding and decoding of signed and unsigned integers when the length of the buffer is known, e.g., when the encoding lies within the body of a BSUP counted-length value.
(b []byte)
| 10 | // value. |
| 11 | |
| 12 | func DecodeCountedUvarint(b []byte) uint64 { |
| 13 | n := len(b) |
| 14 | u64 := uint64(0) |
| 15 | for n > 0 { |
| 16 | n-- |
| 17 | u64 <<= 8 |
| 18 | u64 |= uint64(b[n]) |
| 19 | } |
| 20 | return u64 |
| 21 | } |
| 22 | |
| 23 | func EncodeCountedUvarint(dst []byte, u64 uint64) uint { |
| 24 | var n uint |
no outgoing calls
no test coverage detected