Documentation ¶
Overview ¶
Package walk provides helper functions for traversing all elements in a protobuf file descriptor. There are versions both for traversing "rich" descriptors (protoreflect.Descriptor) and for traversing the underlying "raw" descriptor protos.
Enter And Exit ¶
This package includes variants of the functions that accept two callback functions. These variants have names ending with "EnterAndExit". One function is called as each element is visited ("enter") and the other is called after the element and all of its descendants have been visited ("exit"). This can be useful when you need to track state that is scoped to the visitation of a single element.
Source Path ¶
When traversing raw descriptor protos, this package include variants whose callback accepts a protoreflect.SourcePath. These variants have names that include "WithPath". This path can be used to locate corresponding data in the file's source code info (if present).
Index ¶
- func DescriptorProtos(file *descriptorpb.FileDescriptorProto, ...) error
- func DescriptorProtosEnterAndExit(file *descriptorpb.FileDescriptorProto, ...) error
- func DescriptorProtosWithPath(file *descriptorpb.FileDescriptorProto, ...) error
- func DescriptorProtosWithPathEnterAndExit(file *descriptorpb.FileDescriptorProto, ...) error
- func Descriptors(file protoreflect.FileDescriptor, fn func(protoreflect.Descriptor) error) error
- func DescriptorsEnterAndExit(file protoreflect.FileDescriptor, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DescriptorProtos ¶
func DescriptorProtos(file *descriptorpb.FileDescriptorProto, fn func(protoreflect.FullName, proto.Message) error) error
DescriptorProtos walks all descriptor protos in the given file using a depth-first traversal, calling the given function for each descriptor proto in the hierarchy. The walk ends when traversal is complete or when the function returns an error. If the function returns an error, that is returned as the result of the walk operation.
Descriptor protos are visited using a pre-order traversal, where the function is called for a descriptor before it is called for any of its descendants.
func DescriptorProtosEnterAndExit ¶
func DescriptorProtosEnterAndExit(file *descriptorpb.FileDescriptorProto, enter, exit func(protoreflect.FullName, proto.Message) error) error
DescriptorProtosEnterAndExit walks all descriptor protos in the given file using a depth-first traversal, calling the given functions on entry and on exit for each descriptor in the hierarchy. The walk ends when traversal is complete or when a function returns an error. If a function returns an error, that is returned as the result of the walk operation.
The enter function is called using a pre-order traversal, where the function is called for a descriptor proto before it is called for any of its descendants. The exit function is called using a post-order traversal, where the function is called for a descriptor proto only after it is called for any descendants.
func DescriptorProtosWithPath ¶
func DescriptorProtosWithPath(file *descriptorpb.FileDescriptorProto, fn func(protoreflect.FullName, protoreflect.SourcePath, proto.Message) error) error
DescriptorProtosWithPath walks all descriptor protos in the given file using a depth-first traversal. This is the same as DescriptorProtos except that the callback function, fn, receives a protoreflect.SourcePath, that indicates the path for the element in the file's source code info.
func DescriptorProtosWithPathEnterAndExit ¶
func DescriptorProtosWithPathEnterAndExit(file *descriptorpb.FileDescriptorProto, enter, exit func(protoreflect.FullName, protoreflect.SourcePath, proto.Message) error) error
DescriptorProtosWithPathEnterAndExit walks all descriptor protos in the given file using a depth-first traversal. This is the same as DescriptorProtosEnterAndExit except that the callback function, fn, receives a protoreflect.SourcePath, that indicates the path for the element in the file's source code info.
func Descriptors ¶
func Descriptors(file protoreflect.FileDescriptor, fn func(protoreflect.Descriptor) error) error
Descriptors walks all descriptors in the given file using a depth-first traversal, calling the given function for each descriptor in the hierarchy. The walk ends when traversal is complete or when the function returns an error. If the function returns an error, that is returned as the result of the walk operation.
Descriptors are visited using a pre-order traversal, where the function is called for a descriptor before it is called for any of its descendants.
func DescriptorsEnterAndExit ¶
func DescriptorsEnterAndExit(file protoreflect.FileDescriptor, enter, exit func(protoreflect.Descriptor) error) error
DescriptorsEnterAndExit walks all descriptors in the given file using a depth-first traversal, calling the given functions on entry and on exit for each descriptor in the hierarchy. The walk ends when traversal is complete or when a function returns an error. If a function returns an error, that is returned as the result of the walk operation.
The enter function is called using a pre-order traversal, where the function is called for a descriptor before it is called for any of its descendants. The exit function is called using a post-order traversal, where the function is called for a descriptor only after it is called for any descendants.
Types ¶
This section is empty.