astutil

package
v2.7.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNoopOfStatement

func CreateNoopOfStatement(pkg *types.Package, info *types.Info, stmt ast.Stmt) ast.Stmt

CreateNoopOfStatement creates a syntactically safe noop statement out of a given statement.

func CreateNoopOfStatements

func CreateNoopOfStatements(pkg *types.Package, info *types.Info, stmts []ast.Stmt) ast.Stmt

CreateNoopOfStatements creates a syntactically safe noop statement out of a given statement.

The replacement is anchored at the position of the first original line of code. Without a position the synthesized tokens (the `_` identifiers and the `=`) default to token.NoPos, which sorts before everything; go/printer then floats a leading comment into the middle of the assignment (e.g. `_, _ =\n// comment\ntotal, x`) and the diff's first hunk line points at the comment rather than the code. Anchoring at the original code position keeps a leading comment above the replacement and makes the diff report the correct original line.

func Functions

func Functions(n ast.Node) []*ast.FuncDecl

Functions returns all found functions.

func IdentifiersInStatement

func IdentifiersInStatement(pkg *types.Package, info *types.Info, stmt ast.Stmt) []ast.Expr

IdentifiersInStatement returns all identifiers with their found in a statement.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL