Golang go/ast.Fprint() function example
package go/ast
Fprint prints the (sub-)tree starting at AST node x to w. If fset != nil, position information is interpreted relative to that file set. Otherwise positions are printed as integer values (file set specific offsets).
A non-nil FieldFilter f may be provided to control the output: struct fields for which f(fieldname, fieldvalue) is true are printed; all others are filtered from the output. Unexported struct fields are never printed.
Golang go/ast.Fprint() function usage example
...
var fset = token.NewFileSet()
file, err := parser.ParseFile(fset, "src.go", src, 0)
if err != nil {
fmt.Println(err)
}
var before bytes.Buffer
ast.Fprint(&before, fset, file, nil) // <-- here
...
Reference :
Advertisement
Something interesting
Tutorials
+17.1k Golang : Capture stdout of a child process and act according to the result
+22.4k Golang : How to read JPG(JPEG), GIF and PNG files ?
+7.5k Golang : How to stop user from directly running an executable file?
+10.3k Golang : Wait and sync.WaitGroup example
+19.1k Mac OSX : Homebrew and Golang
+19.4k Golang : Fix cannot download, $GOPATH not set error
+9.6k Golang : Validate IPv6 example
+20.9k PHP : Convert(cast) int to double/float
+5.4k Unix/Linux : How to archive and compress entire directory ?
+6.5k Elasticsearch : Shutdown a local node
+27.5k Golang : dial tcp: too many colons in address