proto

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2026 License: GPL-3.0, Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldTypeVARINT = iota
	FieldTypeI64
	FieldTypeLEN
	FieldTypeSGROUP
	FieldTypeEGROUP
	FieldTypeI32
)

All possible field types declared in https://protobuf.dev/programming-guides/encoding/#structure.

View Source
const MaxFieldNumber = 1<<29 - 1

MaxFieldNumber is a maximum field number according to https://protobuf.dev/programming-guides/proto3/#assigning.

Variables

This section is empty.

Functions

func AssertFieldType

func AssertFieldType(num, got, exp int)

AssertFieldType checks whether field with given number has expected type. If not, AssertFieldType panics.

func CheckFieldType

func CheckFieldType(num, got, exp int) string

CheckFieldType checks whether field with given number has expected type and returns non-empty exception if not.

func EncodeTag

func EncodeTag(num, typ uint64) uint64

EncodeTag encodes protobuf tag for field with given number and type.

func PutUvarint

func PutUvarint(buf []byte, off int, x uint64) int

PutUvarint encodes x into buf with given offset and returns the number of bytes written.

func ReadSizeLEN

func ReadSizeLEN(b []byte) (int, int, string)

ReadSizeLEN reads length of nested FieldTypeLEN field from b. Returns resulting length, number of bytes read and exception.

func ReadTag

func ReadTag(b []byte) (int, int, int, string)

ReadTag reads tag of protobuf field from b. Returns field number, type, number of bytes read and exception.

func ReadUint32

func ReadUint32(b []byte) (uint32, int, string)

ReadUint32 reads protobuf field of uint32 type. Returns field value, number of bytes read and exception.

func SizeLEN

func SizeLEN(ln int) int

SizeLEN returns length of nested FieldTypeLEN field.

func SizeTag

func SizeTag(num uint64) int

SizeTag returns size of protobuf tag for field with given number.

func SizeVarint

func SizeVarint(x uint64) int

SizeVarint returns length of FieldTypeVARINT field.

func StringifyFieldType

func StringifyFieldType(typ int) string

StringifyFieldType stringifies given field type.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL