protopath

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package protopath provides types for representing paths through a protobuf message tree. A Path is a sequence of Steps, where each Step describes a single navigation action: accessing a field by descriptor, indexing into a repeated field, looking up a map key, or expanding an Any message.

Paths are used by the protorange package to report the location of each visited node during message traversal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Path

type Path []Step

Path represents a location in a protobuf message tree as a sequence of Steps from the root message to a specific node.

func (Path) Index

func (p Path) Index(i int) Step

Index returns the step at position i. It panics if i is out of range.

func (Path) Len

func (p Path) Len() int

Len returns the number of steps in the path.

func (Path) String

func (p Path) String() string

String returns a human-readable representation of the full path by concatenating the string representations of each step.

type Step

type Step struct {
	// contains filtered or unexported fields
}

Step represents a single navigation step in a protobuf message tree. A step is one of four kinds: field access (by descriptor), list index, map key, or Any expansion. Use the constructor functions FieldAccess, ListIndex, MapKey, and AnyExpand to create Steps.

func AnyExpand

AnyExpand returns a Step representing the expansion of a google.protobuf.Any message into its concrete message type.

func FieldAccess

func FieldAccess(fd descriptor.FieldDescriptorAccessor) Step

FieldAccess returns a Step representing access to a message field by its descriptor.

func ListIndex

func ListIndex(i int) Step

ListIndex returns a Step representing access to a repeated field element at the given index.

func MapKey

func MapKey(k protoreflect.MapKey) Step

MapKey returns a Step representing access to a map field entry by its key.

func (Step) FieldDescriptor

func (s Step) FieldDescriptor() descriptor.FieldDescriptorAccessor

FieldDescriptor returns the field descriptor for a field access step, or nil if this step is not a field access.

func (Step) String

func (s Step) String() string

String returns a human-readable representation of the step. Field access steps use the field name prefixed with a dot. List index steps use bracket notation. Map key steps use bracket notation with the key value. Any expand steps show the expanded message full name in parentheses.

Jump to

Keyboard shortcuts

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