Golang go/ast.FilterFile() function example
package go/ast
FilterFile trims the AST for a Go file in place by removing all names from top-level declarations (including struct field and interface method names, but not from parameter lists) that don't pass through the filter f. If the declaration is empty afterwards, the declaration is removed from the AST. The File.Comments list is not changed.
FilterFile returns true if there are any top-level declarations left after filtering; it returns false otherwise.
Golang go/ast.FilterFile() function usage example
var PAst map[string]*ast.File
filter := "$" // Regular Expression based filter will be useful
for name, a := range PAst {
ast.FilterFile(a, filter)
…
}
References :
https://github.com/fzipp/pythia/blob/master/third_party/go.tools/godoc/cmdline.go
Advertisement
Something interesting
Tutorials
+36.7k Golang : Display float in 2 decimal points and rounding up or down
+8.3k Golang : Emulate NumPy way of creating matrix example
+14.3k Golang : How to shuffle elements in array or slice?
+31.6k Golang : Get local IP and MAC address
+14k Golang : convert rune to unicode hexadecimal value and back to rune character
+6.5k Golang : Map within a map example
+4k Detect if Google Analytics and Developer Media are loaded properly or not
+12.2k Golang : Simple client-server HMAC authentication without SSL example
+5.2k Golang : Customize scanner.Scanner to treat dash as part of identifier
+8.8k Android Studio : Image button and button example
+8.8k Golang : Random integer with rand.Seed() within a given range
+10.9k Golang : Get UDP client IP address and differentiate clients by port number