mirror of
https://codeberg.org/scip/tablizer.git
synced 2025-12-18 21:11:03 +01:00
added
This commit is contained in:
36
vendor/github.com/shurcooL/go/printerutil/printerutil.go
generated
vendored
Normal file
36
vendor/github.com/shurcooL/go/printerutil/printerutil.go
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// Package printerutil provides formatted printing of AST nodes.
|
||||
package printerutil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/printer"
|
||||
"go/token"
|
||||
)
|
||||
|
||||
// Consistent with the default gofmt behavior.
|
||||
var config = printer.Config{Mode: printer.UseSpaces | printer.TabIndent, Tabwidth: 8}
|
||||
|
||||
// SprintAst prints node, using fset, and returns it as string.
|
||||
func SprintAst(fset *token.FileSet, node interface{}) string {
|
||||
var buf bytes.Buffer
|
||||
config.Fprint(&buf, fset, node)
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// SprintAstBare prints node and returns it as string.
|
||||
func SprintAstBare(node interface{}) string {
|
||||
fset := token.NewFileSet()
|
||||
return SprintAst(fset, node)
|
||||
}
|
||||
|
||||
// PrintlnAst prints node, using fset, to stdout.
|
||||
func PrintlnAst(fset *token.FileSet, node interface{}) {
|
||||
fmt.Println(SprintAst(fset, node))
|
||||
}
|
||||
|
||||
// PrintlnAstBare prints node to stdout.
|
||||
func PrintlnAstBare(node interface{}) {
|
||||
fset := token.NewFileSet()
|
||||
PrintlnAst(fset, node)
|
||||
}
|
||||
Reference in New Issue
Block a user