tree

package
v2.16.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Index

Constants

View Source
const PathMatchAll = "*"

PathMatchAll is a token used as part of a Path to match any key at that level in the nested structure

View Source
const PathMatchList = "[]"

PathMatchList is a token used as part of a Path to match items in a list

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher added in v2.16.0

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

Matcher matches concrete attribute paths against a set of declared path patterns. Patterns use the same tokens as Path.Matches: PathMatchAll for any mapping key and PathMatchList for sequence items.

Matching is exact by construction — declaring a path accepts that node only, not its subtree — so removing one leaf from a declared set reliably surfaces it. Matcher.MayContain tells a caller walking a nested structure when descending can still reach a declared node.

func NewMatcher added in v2.16.0

func NewMatcher(patterns ...Path) *Matcher

NewMatcher returns a Matcher for the given path patterns.

func (*Matcher) Matches added in v2.16.0

func (m *Matcher) Matches(path Path) bool

Matches reports whether path matches one of the declared patterns.

func (*Matcher) MayContain added in v2.16.0

func (m *Matcher) MayContain(path Path) bool

MayContain reports whether path is a strict ancestor of at least one pattern: even when the node itself is not declared, a declared attribute lives somewhere underneath it.

type Path

type Path string

Path is a dotted path of keys to a value in a nested mapping structure. A * section in a path will match any key in the mapping structure.

func NewPath

func NewPath(items ...string) Path

NewPath returns a new Path

func (Path) Last

func (p Path) Last() string

func (Path) Matches

func (p Path) Matches(pattern Path) bool

func (Path) Next

func (p Path) Next(part string) Path

Next returns a new path by append part to the current path

func (Path) Parent

func (p Path) Parent() Path

func (Path) Parts

func (p Path) Parts() []string

func (Path) String

func (p Path) String() string

Jump to

Keyboard shortcuts

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