MCPcopy Index your code
hub / github.com/CrowdStrike/csproto / DecodeTag

Method DecodeTag

decoder.go:130–143  ·  view source on GitHub ↗

DecodeTag decodes a field tag and Protobuf wire type from the stream and returns the values. io.ErrUnexpectedEOF is returned if the operation would read past the end of the data.

()

Source from the content-addressed store, hash-verified

128//
129// io.ErrUnexpectedEOF is returned if the operation would read past the end of the data.
130func (d *Decoder) DecodeTag() (tag int, wireType WireType, err error) {
131 if d.offset >= len(d.p) {
132 return 0, WireTypeVarint, io.ErrUnexpectedEOF
133 }
134 v, n, err := DecodeVarint(d.p[d.offset:])
135 if err != nil {
136 return 0, -1, fmt.Errorf("invalid data at byte %d: %w", d.offset, err)
137 }
138 if n < 1 || v < 1 || v > MaxTagValue {
139 return 0, -1, fmt.Errorf("invalid tag value (%d) at byte %d: %w", v, d.offset, ErrInvalidFieldTag)
140 }
141 d.offset += n
142 return int(v >> 3), WireType(v & 0x7), nil
143}
144
145// DecodeBool decodes a boolean value from the stream and returns the value.
146//

Callers 15

BenchmarkDecodeFixed32Function · 0.95
BenchmarkDecodeFixed64Function · 0.95
TestDecoderSeekFunction · 0.95
TestDecodeBoolFunction · 0.95
TestDecodeStringFunction · 0.95
TestDecodeBytesFunction · 0.95
TestDecodeUInt32Function · 0.95
TestDecodeUInt64Function · 0.95
TestDecodeInt32Function · 0.95
TestDecodeSInt32Function · 0.95

Calls 2

DecodeVarintFunction · 0.85
WireTypeTypeAlias · 0.85

Tested by 15

BenchmarkDecodeFixed32Function · 0.76
BenchmarkDecodeFixed64Function · 0.76
TestDecoderSeekFunction · 0.76
TestDecodeBoolFunction · 0.76
TestDecodeStringFunction · 0.76
TestDecodeBytesFunction · 0.76
TestDecodeUInt32Function · 0.76
TestDecodeUInt64Function · 0.76
TestDecodeInt32Function · 0.76
TestDecodeSInt32Function · 0.76