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
+18.8k Golang : Delete duplicate items from a slice/array
+11k Golang : Replace a parameter's value inside a configuration file example
+11.7k Golang : Calculations using complex numbers example
+5.1k Linux/Unix/MacOSX : Find out which application is listening to port 80 or use which IP version
+7.3k Golang : File system scanning
+15.3k Golang : Get all local users and print out their home directory, description and group id
+28.6k Get file path of temporary file in Go
+8k Findstr command the Grep equivalent for Windows
+10.1k Golang : Check a web page existence with HEAD request example
+10.1k Golang : Compare files modify date example
+9.2k Golang : Create and shuffle deck of cards example
+9.7k Random number generation with crypto/rand in Go