Golang go/ast.FilterDecl() function example
package go/ast
FilterDecl trims the AST for a Go declaration in place by removing all names (including struct field and interface method names, but not from parameter lists) that don't pass through the filter f.
FilterDecl returns true if there are any declared names left after filtering; it returns false otherwise.
Golang go/ast.FilterDecl() function usage example
func filterFile(src *File, f Filter, export bool) bool {
j := 0
for _, d := range src.Decls {
if filterDecl(d, f, export) { // <-- here
src.Decls[j] = d
j++
}
}
src.Decls = src.Decls[0:j]
return j > 0
}
References :
Advertisement
Something interesting
Tutorials
+4.6k JavaScript : Rounding number to decimal formats to display currency
+7.3k Golang : Of hash table and hash map
+13.9k Golang : How to determine if a year is leap year?
+14.5k How to automatically restart your crashed Golang server
+13.6k Golang : Get user input until a command or receive a word to stop
+5.3k Javascript : Shuffle or randomize array example
+15k Golang : package is not in GOROOT during compilation
+9.4k Golang : Web(Javascript) to server-side websocket example
+21.4k Curl usage examples with Golang
+7.3k Golang : Calculate how many weeks left to go in a given year
+5k Golang : Display packages names during compilation
+11.3k Golang : Intercept and process UNIX signals example