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
+9.1k Golang : How to capture return values from goroutines?
+20.7k Android Studio : AlertDialog and EditText to get user string input example
+15.9k Golang : Read a file line by line
+14.3k Golang : How to shuffle elements in array or slice?
+9.3k Golang : Temperatures conversion example
+16.3k Golang : convert string or integer to big.Int type
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+28k Golang : Move file to another directory
+12.5k Golang : Arithmetic operation with numerical slices or arrays example
+32.7k Golang : Regular Expression for alphanumeric and underscore
+11.9k Golang : Determine if time variables have same calendar day
+15.3k Golang : Get query string value on a POST request