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
+5.6k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+24k Golang : Find biggest/largest number in array
+11.7k Golang : Secure file deletion with wipe example
+8.7k Golang : Combine slices but preserve order example
+19.5k Golang : How to Set or Add Header http.ResponseWriter?
+7.7k Golang : Mapping Iban to Dunging alphabets
+6.2k Linux/Unix : Commands that you need to be careful about
+14.6k Golang : GUI with Qt and OpenCV to capture image from camera
+11.3k Golang : How to use if, eq and print properly in html template
+31.6k Golang : Get local IP and MAC address
+14.4k Golang : Parsing or breaking down URL
+17.5k Golang : Find smallest number in array