Documentation
¶
Overview ¶
printerパッケージは、ASTノードの印刷を実装しています。
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fprint ¶
FprintはASTノードを出力に「整形表示」します。 それはデフォルトの設定でConfig.Fprintを呼び出します。 gofmt はインデントにタブを使用し、整列にはスペースを使用することに注意してください。 gofmtと一致する出力にはformat.Node(パッケージgo/format)を使用してください。
Example ¶
printSelf()
Output: funcAST, fset := parseFunc("example_test.go", "printSelf") var buf bytes.Buffer printer.Fprint(&buf, fset, funcAST.Body) s := buf.String() s = s[1 : len(s)-1] s = strings.TrimSpace(strings.ReplaceAll(s, "\n\t", "\n")) fmt.Println(s)
Types ¶
type CommentedNode ¶
type CommentedNode struct { Node any Comments []*ast.CommentGroup }
CommentedNodeは、ASTノードと対応するコメントをまとめたものです。 これは、Fprint 関数の引数として提供することができます。
Click to show internal directories.
Click to hide internal directories.