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
+25.6k Golang : convert rune to integer value
+10.4k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+22.2k Golang : Convert seconds to minutes and remainder seconds
+5.3k Javascript : Shuffle or randomize array example
+8.8k Golang : Random integer with rand.Seed() within a given range
+9.5k Golang : Extract or copy items from map based on value
+14k Golang : Human readable time elapsed format such as 5 days ago
+6.5k Golang : Calculate diameter, circumference, area, sphere surface and volume
+9.8k Golang : Resumable upload to Google Drive(RESTful) example
+19.6k Golang : Close channel after ticker stopped example
+9.6k Golang : Validate IPv6 example
+24k Golang : Call function from another package