protorange

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: 6 Imported by: 0

Documentation

Overview

Package protorange provides depth-first traversal of protobuf messages. The Range function walks a message tree, calling a visitor function at each node (both intermediate and leaf). The visitor receives a protopath.Path describing the location of the current node and a protoreflect.Value containing the node's value.

The visitor controls traversal by its return value: nil continues normally, the Skip sentinel skips the children of the current node, and any other error aborts the traversal immediately.

Index

Constants

This section is empty.

Variables

View Source
var Skip = errors.New("skip")

Skip is a sentinel error returned by a visitor function to skip the children of the current node. When a visitor returns Skip for a message, list, or map node, the traversal does not descend into that node's children but continues with the next sibling.

Functions

func Range

func Range(msg proto.Message, fn func(path protopath.Path, v protoreflect.Value) error) error

Range performs a depth-first traversal of the given message, calling fn at each node in the message tree. The path argument to fn describes the location of the current node relative to the root message. The value argument contains the node's protoreflect.Value.

The fn callback controls traversal through its return value:

  • nil: continue traversal normally
  • Skip: skip the children of the current node (only meaningful for message, list, and map nodes)
  • any other error: abort traversal immediately and return the error

Range returns nil if the entire tree is traversed without error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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