go1.20.5
GoThrough

ast.Bad

// The list of possible Object kinds. const Bad = iota

ast.Con

// The list of possible Object kinds. const Con = iota

ast.FilterFuncDuplicates

// If set, duplicate function declarations are excluded. const FilterFuncDuplicates = iota

ast.FilterImportDuplicates

// If set, duplicate import declarations are excluded. const FilterImportDuplicates = iota

ast.FilterUnassociatedComments

// If set, comments that are not associated with a specific // AST node (as Doc or Comment) are excluded. const FilterUnassociatedComments = iota

ast.Fun

// The list of possible Object kinds. const Fun = iota

ast.Lbl

// The list of possible Object kinds. const Lbl = iota

ast.Pkg

// The list of possible Object kinds. const Pkg = iota

ast.RECV

const RECV = iota

ast.SEND

const SEND = iota

ast.Typ

// The list of possible Object kinds. const Typ = iota

ast.Var

// The list of possible Object kinds. const Var = iota

ast.Decl

// All declaration nodes implement the Decl interface. type Decl interface { Node }

ast.Expr

// All expression nodes implement the Expr interface. type Expr interface { Node }

ast.Node

// All node types implement the Node interface. type Node interface { Pos() token.Pos End() token.Pos }

ast.Spec

// A Spec node represents a single (non-parenthesized) import, // constant, type, or variable declaration. type Spec interface { Node }

ast.Stmt

// All statement nodes implement the Stmt interface. type Stmt interface { Node }

ast.Visitor

// A Visitor's Visit method is invoked for each node encountered by Walk. // If the result visitor w is not nil, Walk visits each of the children // of node with the visitor w, followed by a call of w.Visit(nil). type Visitor interface { Visit(node Node) (w Visitor) }

ast.FileExports

// FileExports trims the AST for a Go source file in place such that // only exported nodes remain: all top-level identifiers which are not exported // and their associated information (such as type, initial value, or function // body) are removed. Non-exported fields and methods of exported types are // stripped. The File.Comments list is not changed. // // FileExports reports whether there are exported declarations. func FileExports(src *File) bool

ast.FilterDecl

// FilterDecl trims the AST for a Go declaration in place by removing // all names (including struct field and interface method names, but // not from parameter lists) that don't pass through the filter f. // // FilterDecl reports whether there are any declared names left after // filtering. func FilterDecl(decl Decl, f Filter) bool

ast.FilterFile

// FilterFile trims the AST for a Go file in place by removing all // names from top-level declarations (including struct field and // interface method names, but not from parameter lists) that don't // pass through the filter f. If the declaration is empty afterwards, // the declaration is removed from the AST. Import declarations are // always removed. The File.Comments list is not changed. // // FilterFile reports whether there are any top-level declarations // left after filtering. func FilterFile(src *File, f Filter) bool

ast.FilterPackage

// FilterPackage trims the AST for a Go package in place by removing // all names from top-level declarations (including struct field and // interface method names, but not from parameter lists) that don't // pass through the filter f. If the declaration is empty afterwards, // the declaration is removed from the AST. The pkg.Files list is not // changed, so that file names and top-level package comments don't get // lost. // // FilterPackage reports whether there are any top-level declarations // left after filtering. func FilterPackage(pkg *Package, f Filter) bool

ast.Fprint

// 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. func Fprint(w io.Writer, fset *token.FileSet, x any, f FieldFilter) error

ast.Inspect

// Inspect traverses an AST in depth-first order: It starts by calling // f(node); node must not be nil. If f returns true, Inspect invokes f // recursively for each of the non-nil children of node, followed by a // call of f(nil). func Inspect(node Node, f func(Node) bool)

ast.IsExported

// IsExported reports whether name starts with an upper-case letter. func IsExported(name string) bool

ast.MergePackageFiles

// MergePackageFiles creates a file AST by merging the ASTs of the // files belonging to a package. The mode flags control merging behavior. func MergePackageFiles(pkg *Package, mode MergeMode) *File

ast.NewCommentMap

// NewCommentMap creates a new comment map by associating comment groups // of the comments list with the nodes of the AST specified by node. // // A comment group g is associated with a node n if: // // - g starts on the same line as n ends // - g starts on the line immediately following n, and there is // at least one empty line after g and before the next node // - g starts before n and is not associated to the node before n // via the previous rules // // NewCommentMap tries to associate a comment group to the "largest" // node possible: For instance, if the comment is a line comment // trailing an assignment, the comment is associated with the entire // assignment rather than just the last operand in the assignment. func NewCommentMap(fset *token.FileSet, node Node, comments []*CommentGroup) CommentMap

ast.NewIdent

// NewIdent creates a new Ident without position. // Useful for ASTs generated by code other than the Go parser. func NewIdent(name string) *Ident

ast.NewObj

// NewObj creates a new object of a given kind and name. func NewObj(kind ObjKind, name string) *Object

ast.NewPackage

// NewPackage creates a new Package node from a set of File nodes. It resolves // unresolved identifiers across files and updates each file's Unresolved list // accordingly. If a non-nil importer and universe scope are provided, they are // used to resolve identifiers not declared in any of the package files. Any // remaining unresolved identifiers are reported as undeclared. If the files // belong to different packages, one package name is selected and files with // different package names are reported and then ignored. // The result is a package node and a scanner.ErrorList if there were errors. func NewPackage(fset *token.FileSet, files map[string]*File, importer Importer, universe *Scope) (*Package, error)

ast.NewScope

// NewScope creates a new scope nested in the outer scope. func NewScope(outer *Scope) *Scope

ast.NotNilFilter

// NotNilFilter returns true for field values that are not nil; // it returns false otherwise. func NotNilFilter(_ string, v reflect.Value) bool