Debian Codegraph @

pdata/internal/proto/marshal.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package proto // import "go.opentelemetry.io/collector/pdata/internal/proto"
5
6 // EncodeVarint encodes the variant at the end of the buffer.
7 func EncodeVarint(buf []byte, offset int, v uint64) int {
8 offset -= Sov(v)
9 base := offset
10 for v >= 1<<7 {
11 buf[offset] = uint8(v&0x7f | 0x80)
12 v >>= 7
13 offset++
14 }
15 buf[offset] = uint8(v)
16 return base
17 }