Golang go/ast.Walk() function examples
package go/ast
Walk traverses an AST in depth-first order: It starts by calling v.Visit(node); node must not be nil. If the visitor w returned by v.Visit(node) is not nil, Walk is invoked recursively with visitor w for each of the non-nil children of node, followed by a call of w.Visit(nil).
Golang go/ast.Walk() function usage examples
Example 1:
// walkFile walks the file's tree.
func (f *File) walkFile(name string, file *ast.File) {
Println("Checking file", name)
ast.Walk(f, file)
}
Example 2:
var f *ast.File
ast.Walk(visitFn(func(n ast.Node) {
sel, ok := n.(*ast.SelectorExpr)
}), f)
Reference :
Advertisement
Something interesting
Tutorials
+10.6k Golang : Simple File Server
+20.2k Golang : How to get struct tag and use field name to retrieve data?
+13.6k Golang : Qt progress dialog example
+18.6k Golang : Generate thumbnails from images
+12.4k Elastic Search : Return all records (higher than default 10)
+33.9k Golang : Call a function after some delay(time.Sleep and Tick)
+12.3k Golang : How to display image file or expose CSS, JS files from localhost?
+9.7k Golang : List available AWS regions
+30.4k Golang : How to verify uploaded file is image or allowed file types
+15k Golang : How do I get the local IP (non-loopback) address ?
+17.5k Golang : Linked list example
+6.8k Golang : Muxing with Martini example