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
+18.1k Golang : Check if a directory exist or not
+10.6k Golang : How to unmarshal JSON inner/nested value and assign to specific struct?
+21.2k Golang : Get password from console input without echo or masked
+7.4k Golang : Accessing dataframe-go element by row, column and name example
+13.8k Golang : Gin framework accept query string by post request example
+14.1k Golang : Check if a file exist or not
+14.5k Golang : How to determine if user agent is a mobile device example
+15.6k Golang : Convert date format and separator yyyy-mm-dd to dd-mm-yyyy
+9.4k Android Studio : Indicate progression with ProgressBar example
+11.6k Golang : Surveillance with web camera and OpenCV
+9k Golang : Go as a script or running go with shebang/hashbang style
+15.9k Golang : Read a file line by line