Files
kubevpn/vendor/github.com/expr-lang/expr/ast/find.go
2025-04-19 10:06:56 +08:00

19 lines
261 B
Go

package ast
func Find(node Node, fn func(node Node) bool) Node {
v := &finder{fn: fn}
Walk(&node, v)
return v.node
}
type finder struct {
node Node
fn func(node Node) bool
}
func (f *finder) Visit(node *Node) {
if f.fn(*node) {
f.node = *node
}
}