Files
2025-03-07 20:40:02 +01: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
}
}