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
+6.9k Golang : Pat multiplexer routing example
+13.4k Golang : Verify token from Google Authenticator App
+4.3k Javascript : How to show different content with noscript?
+6.7k Golang : Derive cryptographic key from passwords with Argon2
+20.9k Golang : Convert PNG transparent background image to JPG or JPEG image
+5.2k PHP : See installed compiled-in-modules
+12.5k Golang : "https://" not allowed in import path
+30k Golang : Get time.Duration in year, month, week or day
+5.4k Golang *File points to a file or directory ?
+10.4k Golang : Generate random integer or float number