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
+23.1k Golang : simulate tail -f or read last line from log file example
+14k Golang : convert rune to unicode hexadecimal value and back to rune character
+8.1k Golang : Randomize letters from a string example
+17.5k Golang : Linked list example
+19.1k Mac OSX : Homebrew and Golang
+17.8k Golang : Defer function inside init()
+4.8k Golang : A program that contain another program and executes it during run-time
+19.4k Golang : How to count the number of repeated characters in a string?
+6.5k Unix/Linux : How to get own IP address ?
+7.7k Gogland : Where to put source code files in package directory for rookie
+25.7k Golang : How to write CSV data to file
+9.6k Golang : Validate IPv6 example