3 ms·
You could do: func inspect(n ast.Node) func(func(ast.Node) bool) { return func(f func(ast.Node) bool) { ast.Inspect(n, f) }
by EdiX 2y ago
You could do:
func inspect(n ast.Node) func(func(ast.Node) bool) {
return func(f func(ast.Node) bool) {
ast.Inspect(n, f)
}
}
used:
for n := range inspect(f) {
fmt.Printf("%T\n", n)
}
- euroderf 2y agoOK, this works cos package ast already has `func Inspect`. So how about a more general case ? A case where we do not have a `func Inspect` already in the stdlib ? Maybe just replace it with (for example) `filepath.WalkDir` ?