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
+13.7k Golang : Check if an integer is negative or positive
+51.1k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+4.4k Golang : Valued expressions and functions example
+10.2k Golang : Find and replace data in all files recursively
+18.6k Golang : Find IP address from string
+8.5k Golang : How to check if input string is a word?
+14.2k Golang : Convert IP version 6 address to integer or decimal number
+8.9k Golang : Sort lines of text example
+14.5k Golang : How to determine if user agent is a mobile device example
+16.1k Golang : Generate universally unique identifier(UUID) example
+7.8k Golang : Load DSA public key from file example
+9.7k Golang : List available AWS regions