Namespace: go.std.go.ast
v1.0Contents
Summary
Provides a low-level interface to the go/ast package.
Package ast declares the types used to represent syntax trees for Go
packages.
Index
- *ArrayType
- *AssignStmt
- *BadDecl
- *BadExpr
- *BadStmt
- *BasicLit
- *BinaryExpr
- *BlockStmt
- *BranchStmt
- *CallExpr
- *CaseClause
- *ChanDir
- *ChanType
- *CommClause
- *Comment
- *CommentGroup
- *CommentMap
- *CompositeLit
- *DeclStmt
- *DeferStmt
- *Ellipsis
- *EmptyStmt
- *ExprStmt
- *Field
- *FieldFilter
- *FieldList
- *File
- *Filter
- *ForStmt
- *FuncDecl
- *FuncLit
- *FuncType
- *GenDecl
- *GoStmt
- *Ident
- *IfStmt
- *ImportSpec
- *Importer
- *IncDecStmt
- *IndexExpr
- *IndexListExpr
- *InterfaceType
- *KeyValueExpr
- *LabeledStmt
- *MapType
- *MergeMode
- *ObjKind
- *Object
- *Package
- *ParenExpr
- *RangeStmt
- *ReturnStmt
- *Scope
- *SelectStmt
- *SelectorExpr
- *SendStmt
- *SliceExpr
- *StarExpr
- *StructType
- *SwitchStmt
- *TypeAssertExpr
- *TypeSpec
- *TypeSwitchStmt
- *UnaryExpr
- *ValueSpec
- ArrayType
- AssignStmt
- Bad
- BadDecl
- BadExpr
- BadStmt
- BasicLit
- BinaryExpr
- BlockStmt
- BranchStmt
- CallExpr
- CaseClause
- ChanDir
- ChanType
- CommClause
- Comment
- CommentGroup
- CommentMap
- CompositeLit
- Con
- Decl
- DeclStmt
- DeferStmt
- Ellipsis
- EmptyStmt
- Expr
- ExprStmt
- Field
- FieldFilter
- FieldList
- File
- FileExports
- Filter
- FilterDecl
- FilterFile
- FilterFuncDuplicates
- FilterImportDuplicates
- FilterPackage
- FilterUnassociatedComments
- ForStmt
- Fprint
- Fun
- FuncDecl
- FuncLit
- FuncType
- GenDecl
- GoStmt
- Ident
- IfStmt
- ImportSpec
- Importer
- IncDecStmt
- IndexExpr
- IndexListExpr
- InterfaceType
- IsExported
- KeyValueExpr
- LabeledStmt
- Lbl
- MapType
- MergeMode
- MergePackageFiles
- NewCommentMap
- NewIdent
- NewObj
- NewScope
- Node
- NotNilFilter
- ObjKind
- Object
- Package
- PackageExports
- ParenExpr
- Pkg
- RECV
- RangeStmt
- ReturnStmt
- SEND
- Scope
- SelectStmt
- SelectorExpr
- SendStmt
- SliceExpr
- SortImports
- Spec
- StarExpr
- Stmt
- StructType
- SwitchStmt
- Typ
- TypeAssertExpr
- TypeSpec
- TypeSwitchStmt
- UnaryExpr
- ValueSpec
- Var
- Visitor
- Walk
- arrayOfArrayType
- arrayOfAssignStmt
- arrayOfBadDecl
- arrayOfBadExpr
- arrayOfBadStmt
- arrayOfBasicLit
- arrayOfBinaryExpr
- arrayOfBlockStmt
- arrayOfBranchStmt
- arrayOfCallExpr
- arrayOfCaseClause
- arrayOfChanDir
- arrayOfChanType
- arrayOfCommClause
- arrayOfComment
- arrayOfCommentGroup
- arrayOfCommentMap
- arrayOfCompositeLit
- arrayOfDecl
- arrayOfDeclStmt
- arrayOfDeferStmt
- arrayOfEllipsis
- arrayOfEmptyStmt
- arrayOfExpr
- arrayOfExprStmt
- arrayOfField
- arrayOfFieldFilter
- arrayOfFieldList
- arrayOfFile
- arrayOfFilter
- arrayOfForStmt
- arrayOfFuncDecl
- arrayOfFuncLit
- arrayOfFuncType
- arrayOfGenDecl
- arrayOfGoStmt
- arrayOfIdent
- arrayOfIfStmt
- arrayOfImportSpec
- arrayOfImporter
- arrayOfIncDecStmt
- arrayOfIndexExpr
- arrayOfIndexListExpr
- arrayOfInterfaceType
- arrayOfKeyValueExpr
- arrayOfLabeledStmt
- arrayOfMapType
- arrayOfMergeMode
- arrayOfNode
- arrayOfObjKind
- arrayOfObject
- arrayOfPackage
- arrayOfParenExpr
- arrayOfRangeStmt
- arrayOfReturnStmt
- arrayOfScope
- arrayOfSelectStmt
- arrayOfSelectorExpr
- arrayOfSendStmt
- arrayOfSliceExpr
- arrayOfSpec
- arrayOfStarExpr
- arrayOfStmt
- arrayOfStructType
- arrayOfSwitchStmt
- arrayOfTypeAssertExpr
- arrayOfTypeSpec
- arrayOfTypeSwitchStmt
- arrayOfUnaryExpr
- arrayOfValueSpec
- arrayOfVisitor
Legend
-
Constant
Variable
Function
Macro
Special form
Type
GoVar
Receiver/Method
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
(None.)
Variables
-
Bad
GoObject v1.0for error handling
-
Con
GoObject v1.0constant
-
FilterFuncDuplicates
GoObject v1.0If set, duplicate function declarations are excluded.
-
FilterImportDuplicates
GoObject v1.0If set, duplicate import declarations are excluded.
-
FilterUnassociatedComments
GoObject v1.0If set, comments that are not associated with a specific
AST node (as Doc or Comment) are excluded.
-
Fun
GoObject v1.0function or method
-
Lbl
GoObject v1.0label
-
Pkg
GoObject v1.0package
-
RECV
GoObject v1.0 -
SEND
GoObject v1.0 -
Typ
GoObject v1.0type
-
Var
GoObject v1.0variable
Functions, Macros, and Special Forms
-
FileExports
Function v1.0(FileExports src)
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.
Go input arguments: (src *File)
Go returns: bool
Joker input arguments: [^*File src]
Joker returns: ^Boolean -
FilterDecl
Function v1.0(FilterDecl decl f)
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.
Go input arguments: (decl Decl, f Filter)
Go returns: bool
Joker input arguments: [^Decl decl, ^Filter f]
Joker returns: ^Boolean -
FilterFile
Function v1.0(FilterFile src f)
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.
Go input arguments: (src *File, f Filter)
Go returns: bool
Joker input arguments: [^*File src, ^Filter f]
Joker returns: ^Boolean -
FilterPackage
Function v1.0(FilterPackage pkg f)
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.
Go input arguments: (pkg *Package, f Filter)
Go returns: bool
Joker input arguments: [^*Package pkg, ^Filter f]
Joker returns: ^Boolean -
Fprint
Function v1.0(Fprint w fset x f)
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.
Go input arguments: (w io.Writer, fset *go/token.FileSet, x any, f FieldFilter)
Go returns: error
Joker input arguments: [^go.std.io/Writer w, ^go.std.go.token/*FileSet fset, ^GoObject x, ^FieldFilter f]
Joker returns: ^Error -
IsExported
Function v1.0(IsExported name)
IsExported reports whether name starts with an upper-case letter.
Go input arguments: (name string)
Go returns: bool
Joker input arguments: [^String name]
Joker returns: ^Boolean -
MergePackageFiles
Function v1.0(MergePackageFiles pkg mode)
MergePackageFiles creates a file AST by merging the ASTs of the
files belonging to a package. The mode flags control merging behavior.
Go input arguments: (pkg *Package, mode MergeMode)
Go returns: *File
Joker input arguments: [^*Package pkg, ^MergeMode mode]
Joker returns: ^*File -
NewCommentMap
Function v1.0(NewCommentMap fset node comments)
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.
Go input arguments: (fset *go/token.FileSet, node Node, comments []*CommentGroup)
Go returns: CommentMap
Joker input arguments: [^go.std.go.token/*FileSet fset, ^Node node, ^arrayOf*CommentGroup comments]
Joker returns: ^CommentMap -
NewIdent
Function v1.0(NewIdent name)
NewIdent creates a new Ident without position.
Useful for ASTs generated by code other than the Go parser.
Go input arguments: (name string)
Go returns: *Ident
Joker input arguments: [^String name]
Joker returns: ^*Ident -
NewObj
Function v1.0(NewObj kind name)
NewObj creates a new object of a given kind and name.
Go input arguments: (kind ObjKind, name string)
Go returns: *Object
Joker input arguments: [^ObjKind kind, ^String name]
Joker returns: ^*Object -
NewScope
Function v1.0(NewScope outer)
NewScope creates a new scope nested in the outer scope.
Go input arguments: (outer *Scope)
Go returns: *Scope
Joker input arguments: [^*Scope outer]
Joker returns: ^*Scope -
NotNilFilter
Function v1.0(NotNilFilter _ v)
NotNilFilter returns true for field values that are not nil;
it returns false otherwise.
Go input arguments: (_ string, v reflect.Value)
Go returns: bool
Joker input arguments: [^String _, ^go.std.reflect/Value v]
Joker returns: ^Boolean -
PackageExports
Function v1.0(PackageExports pkg)
PackageExports trims the AST for a Go package in place such that
only exported nodes remain. The pkg.Files list is not changed, so that
file names and top-level package comments don't get lost.
PackageExports reports whether there are exported declarations;
it returns false otherwise.
Go input arguments: (pkg *Package)
Go returns: bool
Joker input arguments: [^*Package pkg]
Joker returns: ^Boolean -
Print
Function v1.0(Print fset x)
Print prints x to standard output, skipping nil fields.
Print(fset, x) is the same as Fprint(os.Stdout, fset, x, NotNilFilter).
Go input arguments: (fset *go/token.FileSet, x any)
Go returns: error
Joker input arguments: [^go.std.go.token/*FileSet fset, ^GoObject x]
Joker returns: ^Error -
SortImports
Function v1.0(SortImports fset f)
SortImports sorts runs of consecutive import lines in import blocks in f.
It also removes duplicate imports when it is possible to do so without data loss.
Go input arguments: (fset *go/token.FileSet, f *File)
Joker input arguments: [^go.std.go.token/*FileSet fset, ^*File f] -
Walk
Function v1.0(Walk v node)
Walk traverses an AST in depth-first order: It starts by calling
v.Visit(node); node must not be nil. If the visitor w returned by
v.Visit(node) is not nil, Walk is invoked recursively with visitor
w for each of the non-nil children of node, followed by a call of
w.Visit(nil).
Go input arguments: (v Visitor, node Node)
Joker input arguments: [^Visitor v, ^Node node]
Types
-
*ArrayType
Concrete Type v1.0An ArrayType node represents an array or slice type.
-
End
Receiver for *ArrayType v1.0([])
-
Pos
Receiver for *ArrayType v1.0([])
-
*AssignStmt
Concrete Type v1.0An AssignStmt node represents an assignment or
a short variable declaration.
-
End
Receiver for *AssignStmt v1.0([])
-
Pos
Receiver for *AssignStmt v1.0([])
-
*BadDecl
Concrete Type v1.0A BadDecl node is a placeholder for a declaration containing
syntax errors for which a correct declaration node cannot be
created.
-
End
Receiver for *BadDecl v1.0([])
-
Pos
Receiver for *BadDecl v1.0([])
-
*BadExpr
Concrete Type v1.0A BadExpr node is a placeholder for an expression containing
syntax errors for which a correct expression node cannot be
created.
-
End
Receiver for *BadExpr v1.0([])
-
Pos
Receiver for *BadExpr v1.0([])
-
*BadStmt
Concrete Type v1.0A BadStmt node is a placeholder for statements containing
syntax errors for which no correct statement nodes can be
created.
-
End
Receiver for *BadStmt v1.0([])
-
Pos
Receiver for *BadStmt v1.0([])
-
*BasicLit
Concrete Type v1.0A BasicLit node represents a literal of basic type.
-
End
Receiver for *BasicLit v1.0([])
-
Pos
Receiver for *BasicLit v1.0([])
-
*BinaryExpr
Concrete Type v1.0A BinaryExpr node represents a binary expression.
-
End
Receiver for *BinaryExpr v1.0([])
-
Pos
Receiver for *BinaryExpr v1.0([])
-
*BlockStmt
Concrete Type v1.0A BlockStmt node represents a braced statement list.
-
End
Receiver for *BlockStmt v1.0([])
-
Pos
Receiver for *BlockStmt v1.0([])
-
*BranchStmt
Concrete Type v1.0A BranchStmt node represents a break, continue, goto,
or fallthrough statement.
-
End
Receiver for *BranchStmt v1.0([])
-
Pos
Receiver for *BranchStmt v1.0([])
-
*CallExpr
Concrete Type v1.0A CallExpr node represents an expression followed by an argument list.
-
End
Receiver for *CallExpr v1.0([])
-
Pos
Receiver for *CallExpr v1.0([])
-
*CaseClause
Concrete Type v1.0A CaseClause represents a case of an expression or type switch statement.
-
End
Receiver for *CaseClause v1.0([])
-
Pos
Receiver for *CaseClause v1.0([])
-
*ChanDir
Concrete Type v1.0The direction of a channel type is indicated by a bit
mask including one or both of the following constants.
-
*ChanType
Concrete Type v1.0A ChanType node represents a channel type.
-
End
Receiver for *ChanType v1.0([])
-
Pos
Receiver for *ChanType v1.0([])
-
*CommClause
Concrete Type v1.0A CommClause node represents a case of a select statement.
-
End
Receiver for *CommClause v1.0([])
-
Pos
Receiver for *CommClause v1.0([])
-
*Comment
Concrete Type v1.0A Comment node represents a single //-style or /*-style comment.
The Text field contains the comment text without carriage returns (\r) that
may have been present in the source. Because a comment's end position is
computed using len(Text), the position reported by End() does not match the
true source end position for comments containing carriage returns.
-
End
Receiver for *Comment v1.0([])
-
Pos
Receiver for *Comment v1.0([])
-
*CommentGroup
Concrete Type v1.0A CommentGroup represents a sequence of comments
with no other tokens and no empty lines between.
-
End
Receiver for *CommentGroup v1.0([])
-
Pos
Receiver for *CommentGroup v1.0([])
-
Text
Receiver for *CommentGroup v1.0([])
Text returns the text of the comment.
Comment markers (//, /*, and */), the first space of a line comment, and
leading and trailing empty lines are removed.
Comment directives like "//line" and "//go:noinline" are also removed.
Multiple empty lines are reduced to one, and trailing space on lines is trimmed.
Unless the result is empty, it is newline-terminated.
-
*CommentMap
Concrete Type v1.0A CommentMap maps an AST node to a list of comment groups
associated with it. See NewCommentMap for a description of
the association.
-
*CompositeLit
Concrete Type v1.0A CompositeLit node represents a composite literal.
-
End
Receiver for *CompositeLit v1.0([])
-
Pos
Receiver for *CompositeLit v1.0([])
-
*DeclStmt
Concrete Type v1.0A DeclStmt node represents a declaration in a statement list.
-
End
Receiver for *DeclStmt v1.0([])
-
Pos
Receiver for *DeclStmt v1.0([])
-
*DeferStmt
Concrete Type v1.0A DeferStmt node represents a defer statement.
-
End
Receiver for *DeferStmt v1.0([])
-
Pos
Receiver for *DeferStmt v1.0([])
-
*Ellipsis
Concrete Type v1.0An Ellipsis node stands for the "..." type in a
parameter list or the "..." length in an array type.
-
End
Receiver for *Ellipsis v1.0([])
-
Pos
Receiver for *Ellipsis v1.0([])
-
*EmptyStmt
Concrete Type v1.0An EmptyStmt node represents an empty statement.
The "position" of the empty statement is the position
of the immediately following (explicit or implicit) semicolon.
-
End
Receiver for *EmptyStmt v1.0([])
-
Pos
Receiver for *EmptyStmt v1.0([])
-
*ExprStmt
Concrete Type v1.0An ExprStmt node represents a (stand-alone) expression
in a statement list.
-
End
Receiver for *ExprStmt v1.0([])
-
Pos
Receiver for *ExprStmt v1.0([])
-
*Field
Concrete Type v1.0A Field represents a Field declaration list in a struct type,
a method list in an interface type, or a parameter/result declaration
in a signature.
Field.Names is nil for unnamed parameters (parameter lists which only contain types)
and embedded struct fields. In the latter case, the field name is the type name.
-
End
Receiver for *Field v1.0([])
-
Pos
Receiver for *Field v1.0([])
-
*FieldFilter
Concrete Type v1.0A FieldFilter may be provided to Fprint to control the output.
-
*FieldList
Concrete Type v1.0A FieldList represents a list of Fields, enclosed by parentheses,
curly braces, or square brackets.
-
End
Receiver for *FieldList v1.0([])
-
NumFields
Receiver for *FieldList v1.0([])
NumFields returns the number of parameters or struct fields represented by a FieldList.
-
Pos
Receiver for *FieldList v1.0([])
-
*File
Concrete Type v1.0A File node represents a Go source file.
The Comments list contains all comments in the source file in order of
appearance, including the comments that are pointed to from other nodes
via Doc and Comment fields.
For correct printing of source code containing comments (using packages
go/format and go/printer), special care must be taken to update comments
when a File's syntax tree is modified: For printing, comments are interspersed
between tokens based on their position. If syntax tree nodes are
removed or moved, relevant comments in their vicinity must also be removed
(from the File.Comments list) or moved accordingly (by updating their
positions). A CommentMap may be used to facilitate some of these operations.
Whether and how a comment is associated with a node depends on the
interpretation of the syntax tree by the manipulating program: Except for Doc
and Comment comments directly associated with nodes, the remaining comments
are "free-floating" (see also issues #18593, #20744).
-
End
Receiver for *File v1.0([])
-
Pos
Receiver for *File v1.0([])
-
*Filter
Concrete Type v1.0 -
*ForStmt
Concrete Type v1.0A ForStmt represents a for statement.
-
End
Receiver for *ForStmt v1.0([])
-
Pos
Receiver for *ForStmt v1.0([])
-
*FuncDecl
Concrete Type v1.0A FuncDecl node represents a function declaration.
-
End
Receiver for *FuncDecl v1.0([])
-
Pos
Receiver for *FuncDecl v1.0([])
-
*FuncLit
Concrete Type v1.0A FuncLit node represents a function literal.
-
End
Receiver for *FuncLit v1.0([])
-
Pos
Receiver for *FuncLit v1.0([])
-
*FuncType
Concrete Type v1.0A FuncType node represents a function type.
-
End
Receiver for *FuncType v1.0([])
-
Pos
Receiver for *FuncType v1.0([])
-
*GenDecl
Concrete Type v1.0A GenDecl node (generic declaration node) represents an import,
constant, type or variable declaration. A valid Lparen position
(Lparen.IsValid()) indicates a parenthesized declaration.
Relationship between Tok value and Specs element type:
token.IMPORT *ImportSpec
token.CONST *ValueSpec
token.TYPE *TypeSpec
token.VAR *ValueSpec
-
End
Receiver for *GenDecl v1.0([])
-
Pos
Receiver for *GenDecl v1.0([])
-
*GoStmt
Concrete Type v1.0A GoStmt node represents a go statement.
-
End
Receiver for *GoStmt v1.0([])
-
Pos
Receiver for *GoStmt v1.0([])
-
*Ident
Concrete Type v1.0An Ident node represents an identifier.
-
End
Receiver for *Ident v1.0([])
-
IsExported
Receiver for *Ident v1.0([])
IsExported reports whether id starts with an upper-case letter.
-
Pos
Receiver for *Ident v1.0([])
-
String
Receiver for *Ident v1.0([])
-
*IfStmt
Concrete Type v1.0An IfStmt node represents an if statement.
-
End
Receiver for *IfStmt v1.0([])
-
Pos
Receiver for *IfStmt v1.0([])
-
*ImportSpec
Concrete Type v1.0An ImportSpec node represents a single package import.
-
End
Receiver for *ImportSpec v1.0([])
-
Pos
Receiver for *ImportSpec v1.0([])
-
*Importer
Concrete Type v1.0An Importer resolves import paths to package Objects.
The imports map records the packages already imported,
indexed by package id (canonical import path).
An Importer must determine the canonical import path and
check the map to see if it is already present in the imports map.
If so, the Importer can return the map entry. Otherwise, the
Importer should load the package data for the given path into
a new *Object (pkg), record pkg in the imports map, and then
return pkg.
-
*IncDecStmt
Concrete Type v1.0An IncDecStmt node represents an increment or decrement statement.
-
End
Receiver for *IncDecStmt v1.0([])
-
Pos
Receiver for *IncDecStmt v1.0([])
-
*IndexExpr
Concrete Type v1.0An IndexExpr node represents an expression followed by an index.
-
End
Receiver for *IndexExpr v1.0([])
-
Pos
Receiver for *IndexExpr v1.0([])
-
*IndexListExpr
Concrete Type v1.0An IndexListExpr node represents an expression followed by multiple
indices.
-
End
Receiver for *IndexListExpr v1.0([])
-
Pos
Receiver for *IndexListExpr v1.0([])
-
*InterfaceType
Concrete Type v1.0An InterfaceType node represents an interface type.
-
End
Receiver for *InterfaceType v1.0([])
-
Pos
Receiver for *InterfaceType v1.0([])
-
*KeyValueExpr
Concrete Type v1.0A KeyValueExpr node represents (key : value) pairs
in composite literals.
-
End
Receiver for *KeyValueExpr v1.0([])
-
Pos
Receiver for *KeyValueExpr v1.0([])
-
*LabeledStmt
Concrete Type v1.0A LabeledStmt node represents a labeled statement.
-
End
Receiver for *LabeledStmt v1.0([])
-
Pos
Receiver for *LabeledStmt v1.0([])
-
*MapType
Concrete Type v1.0A MapType node represents a map type.
-
End
Receiver for *MapType v1.0([])
-
Pos
Receiver for *MapType v1.0([])
-
*MergeMode
Concrete Type v1.0The MergeMode flags control the behavior of MergePackageFiles.
-
*ObjKind
Concrete Type v1.0ObjKind describes what an object represents.
-
*Object
Concrete Type v1.0An Object describes a named language entity such as a package,
constant, type, variable, function (incl. methods), or label.
The Data fields contains object-specific data:
Kind Data type Data value
Pkg *Scope package scope
Con int iota for the respective declaration
-
Pos
Receiver for *Object v1.0([])
Pos computes the source position of the declaration of an object name.
The result may be an invalid position if it cannot be computed
(obj.Decl may be nil or not correct).
-
*Package
Concrete Type v1.0A Package node represents a set of source files
collectively building a Go package.
-
End
Receiver for *Package v1.0([])
-
Pos
Receiver for *Package v1.0([])
-
*ParenExpr
Concrete Type v1.0A ParenExpr node represents a parenthesized expression.
-
End
Receiver for *ParenExpr v1.0([])
-
Pos
Receiver for *ParenExpr v1.0([])
-
*RangeStmt
Concrete Type v1.0A RangeStmt represents a for statement with a range clause.
-
End
Receiver for *RangeStmt v1.0([])
-
Pos
Receiver for *RangeStmt v1.0([])
-
*ReturnStmt
Concrete Type v1.0A ReturnStmt node represents a return statement.
-
End
Receiver for *ReturnStmt v1.0([])
-
Pos
Receiver for *ReturnStmt v1.0([])
-
*Scope
Concrete Type v1.0A Scope maintains the set of named language entities declared
in the scope and a link to the immediately surrounding (outer)
scope.
-
Insert
Receiver for *Scope v1.0([obj])
Insert attempts to insert a named object obj into the scope s.
If the scope already contains an object alt with the same name,
Insert leaves the scope unchanged and returns alt. Otherwise
it inserts obj and returns nil.
-
Lookup
Receiver for *Scope v1.0([name])
Lookup returns the object with the given name if it is
found in scope s, otherwise it returns nil. Outer scopes
are ignored.
-
String
Receiver for *Scope v1.0([])
Debugging support
-
*SelectStmt
Concrete Type v1.0A SelectStmt node represents a select statement.
-
End
Receiver for *SelectStmt v1.0([])
-
Pos
Receiver for *SelectStmt v1.0([])
-
*SelectorExpr
Concrete Type v1.0A SelectorExpr node represents an expression followed by a selector.
-
End
Receiver for *SelectorExpr v1.0([])
-
Pos
Receiver for *SelectorExpr v1.0([])
-
*SendStmt
Concrete Type v1.0A SendStmt node represents a send statement.
-
End
Receiver for *SendStmt v1.0([])
-
Pos
Receiver for *SendStmt v1.0([])
-
*SliceExpr
Concrete Type v1.0A SliceExpr node represents an expression followed by slice indices.
-
End
Receiver for *SliceExpr v1.0([])
-
Pos
Receiver for *SliceExpr v1.0([])
-
*StarExpr
Concrete Type v1.0A StarExpr node represents an expression of the form "*" Expression.
Semantically it could be a unary "*" expression, or a pointer type.
-
End
Receiver for *StarExpr v1.0([])
-
Pos
Receiver for *StarExpr v1.0([])
-
*StructType
Concrete Type v1.0A StructType node represents a struct type.
-
End
Receiver for *StructType v1.0([])
-
Pos
Receiver for *StructType v1.0([])
-
*SwitchStmt
Concrete Type v1.0A SwitchStmt node represents an expression switch statement.
-
End
Receiver for *SwitchStmt v1.0([])
-
Pos
Receiver for *SwitchStmt v1.0([])
-
*TypeAssertExpr
Concrete Type v1.0A TypeAssertExpr node represents an expression followed by a
type assertion.
-
End
Receiver for *TypeAssertExpr v1.0([])
-
Pos
Receiver for *TypeAssertExpr v1.0([])
-
*TypeSpec
Concrete Type v1.0A TypeSpec node represents a type declaration (TypeSpec production).
-
End
Receiver for *TypeSpec v1.0([])
-
Pos
Receiver for *TypeSpec v1.0([])
-
*TypeSwitchStmt
Concrete Type v1.0A TypeSwitchStmt node represents a type switch statement.
-
End
Receiver for *TypeSwitchStmt v1.0([])
-
Pos
Receiver for *TypeSwitchStmt v1.0([])
-
*UnaryExpr
Concrete Type v1.0A UnaryExpr node represents a unary expression.
Unary "*" expressions are represented via StarExpr nodes.
-
End
Receiver for *UnaryExpr v1.0([])
-
Pos
Receiver for *UnaryExpr v1.0([])
-
*ValueSpec
Concrete Type v1.0A ValueSpec node represents a constant or variable declaration
(ConstSpec or VarSpec production).
-
End
Receiver for *ValueSpec v1.0([])
-
Pos
Receiver for *ValueSpec v1.0([])
-
ArrayType
Concrete Type v1.0An ArrayType node represents an array or slice type.
-
AssignStmt
Concrete Type v1.0An AssignStmt node represents an assignment or
a short variable declaration.
-
BadDecl
Concrete Type v1.0A BadDecl node is a placeholder for a declaration containing
syntax errors for which a correct declaration node cannot be
created.
-
BadExpr
Concrete Type v1.0A BadExpr node is a placeholder for an expression containing
syntax errors for which a correct expression node cannot be
created.
-
BadStmt
Concrete Type v1.0A BadStmt node is a placeholder for statements containing
syntax errors for which no correct statement nodes can be
created.
-
BasicLit
Concrete Type v1.0A BasicLit node represents a literal of basic type.
-
BinaryExpr
Concrete Type v1.0A BinaryExpr node represents a binary expression.
-
BlockStmt
Concrete Type v1.0A BlockStmt node represents a braced statement list.
-
BranchStmt
Concrete Type v1.0A BranchStmt node represents a break, continue, goto,
or fallthrough statement.
-
CallExpr
Concrete Type v1.0A CallExpr node represents an expression followed by an argument list.
-
CaseClause
Concrete Type v1.0A CaseClause represents a case of an expression or type switch statement.
-
ChanDir
Concrete Type v1.0The direction of a channel type is indicated by a bit
mask including one or both of the following constants.
-
ChanType
Concrete Type v1.0A ChanType node represents a channel type.
-
CommClause
Concrete Type v1.0A CommClause node represents a case of a select statement.
-
Comment
Concrete Type v1.0A Comment node represents a single //-style or /*-style comment.
The Text field contains the comment text without carriage returns (\r) that
may have been present in the source. Because a comment's end position is
computed using len(Text), the position reported by End() does not match the
true source end position for comments containing carriage returns.
-
CommentGroup
Concrete Type v1.0A CommentGroup represents a sequence of comments
with no other tokens and no empty lines between.
-
CommentMap
Concrete Type v1.0A CommentMap maps an AST node to a list of comment groups
associated with it. See NewCommentMap for a description of
the association.
-
Comments
Receiver for CommentMap v1.0([])
Comments returns the list of comment groups in the comment map.
The result is sorted in source order.
-
Filter
Receiver for CommentMap v1.0([node])
Filter returns a new comment map consisting of only those
entries of cmap for which a corresponding node exists in
the AST specified by node.
-
String
Receiver for CommentMap v1.0([])
-
Update
Receiver for CommentMap v1.0([old new])
Update replaces an old node in the comment map with the new node
and returns the new node. Comments that were associated with the
old node are associated with the new node.
-
CompositeLit
Concrete Type v1.0A CompositeLit node represents a composite literal.
-
Decl
Abstract Type v1.0All declaration nodes implement the Decl interface.
-
End
Method for Decl v1.0([])
-
Pos
Method for Decl v1.0([])
-
DeclStmt
Concrete Type v1.0A DeclStmt node represents a declaration in a statement list.
-
DeferStmt
Concrete Type v1.0A DeferStmt node represents a defer statement.
-
Ellipsis
Concrete Type v1.0An Ellipsis node stands for the "..." type in a
parameter list or the "..." length in an array type.
-
EmptyStmt
Concrete Type v1.0An EmptyStmt node represents an empty statement.
The "position" of the empty statement is the position
of the immediately following (explicit or implicit) semicolon.
-
Expr
Abstract Type v1.0All expression nodes implement the Expr interface.
-
End
Method for Expr v1.0([])
-
Pos
Method for Expr v1.0([])
-
ExprStmt
Concrete Type v1.0An ExprStmt node represents a (stand-alone) expression
in a statement list.
-
Field
Concrete Type v1.0A Field represents a Field declaration list in a struct type,
a method list in an interface type, or a parameter/result declaration
in a signature.
Field.Names is nil for unnamed parameters (parameter lists which only contain types)
and embedded struct fields. In the latter case, the field name is the type name.
-
FieldFilter
Concrete Type v1.0A FieldFilter may be provided to Fprint to control the output.
-
FieldList
Concrete Type v1.0A FieldList represents a list of Fields, enclosed by parentheses,
curly braces, or square brackets.
-
File
Concrete Type v1.0A File node represents a Go source file.
The Comments list contains all comments in the source file in order of
appearance, including the comments that are pointed to from other nodes
via Doc and Comment fields.
For correct printing of source code containing comments (using packages
go/format and go/printer), special care must be taken to update comments
when a File's syntax tree is modified: For printing, comments are interspersed
between tokens based on their position. If syntax tree nodes are
removed or moved, relevant comments in their vicinity must also be removed
(from the File.Comments list) or moved accordingly (by updating their
positions). A CommentMap may be used to facilitate some of these operations.
Whether and how a comment is associated with a node depends on the
interpretation of the syntax tree by the manipulating program: Except for Doc
and Comment comments directly associated with nodes, the remaining comments
are "free-floating" (see also issues #18593, #20744).
-
Filter
Concrete Type v1.0 -
ForStmt
Concrete Type v1.0A ForStmt represents a for statement.
-
FuncDecl
Concrete Type v1.0A FuncDecl node represents a function declaration.
-
FuncLit
Concrete Type v1.0A FuncLit node represents a function literal.
-
FuncType
Concrete Type v1.0A FuncType node represents a function type.
-
GenDecl
Concrete Type v1.0A GenDecl node (generic declaration node) represents an import,
constant, type or variable declaration. A valid Lparen position
(Lparen.IsValid()) indicates a parenthesized declaration.
Relationship between Tok value and Specs element type:
token.IMPORT *ImportSpec
token.CONST *ValueSpec
token.TYPE *TypeSpec
token.VAR *ValueSpec
-
GoStmt
Concrete Type v1.0A GoStmt node represents a go statement.
-
Ident
Concrete Type v1.0An Ident node represents an identifier.
-
IfStmt
Concrete Type v1.0An IfStmt node represents an if statement.
-
ImportSpec
Concrete Type v1.0An ImportSpec node represents a single package import.
-
Importer
Concrete Type v1.0An Importer resolves import paths to package Objects.
The imports map records the packages already imported,
indexed by package id (canonical import path).
An Importer must determine the canonical import path and
check the map to see if it is already present in the imports map.
If so, the Importer can return the map entry. Otherwise, the
Importer should load the package data for the given path into
a new *Object (pkg), record pkg in the imports map, and then
return pkg.
-
IncDecStmt
Concrete Type v1.0An IncDecStmt node represents an increment or decrement statement.
-
IndexExpr
Concrete Type v1.0An IndexExpr node represents an expression followed by an index.
-
IndexListExpr
Concrete Type v1.0An IndexListExpr node represents an expression followed by multiple
indices.
-
InterfaceType
Concrete Type v1.0An InterfaceType node represents an interface type.
-
KeyValueExpr
Concrete Type v1.0A KeyValueExpr node represents (key : value) pairs
in composite literals.
-
LabeledStmt
Concrete Type v1.0A LabeledStmt node represents a labeled statement.
-
MapType
Concrete Type v1.0A MapType node represents a map type.
-
MergeMode
Concrete Type v1.0The MergeMode flags control the behavior of MergePackageFiles.
-
Node
Abstract Type v1.0All node types implement the Node interface.
-
End
Method for Node v1.0([])
-
Pos
Method for Node v1.0([])
-
ObjKind
Concrete Type v1.0ObjKind describes what an object represents.
-
String
Receiver for ObjKind v1.0([])
-
Object
Concrete Type v1.0An Object describes a named language entity such as a package,
constant, type, variable, function (incl. methods), or label.
The Data fields contains object-specific data:
Kind Data type Data value
Pkg *Scope package scope
Con int iota for the respective declaration
-
Package
Concrete Type v1.0A Package node represents a set of source files
collectively building a Go package.
-
ParenExpr
Concrete Type v1.0A ParenExpr node represents a parenthesized expression.
-
RangeStmt
Concrete Type v1.0A RangeStmt represents a for statement with a range clause.
-
ReturnStmt
Concrete Type v1.0A ReturnStmt node represents a return statement.
-
Scope
Concrete Type v1.0A Scope maintains the set of named language entities declared
in the scope and a link to the immediately surrounding (outer)
scope.
-
SelectStmt
Concrete Type v1.0A SelectStmt node represents a select statement.
-
SelectorExpr
Concrete Type v1.0A SelectorExpr node represents an expression followed by a selector.
-
SendStmt
Concrete Type v1.0A SendStmt node represents a send statement.
-
SliceExpr
Concrete Type v1.0A SliceExpr node represents an expression followed by slice indices.
-
Spec
Abstract Type v1.0The Spec type stands for any of *ImportSpec, *ValueSpec, and *TypeSpec.
-
End
Method for Spec v1.0([])
-
Pos
Method for Spec v1.0([])
-
StarExpr
Concrete Type v1.0A StarExpr node represents an expression of the form "*" Expression.
Semantically it could be a unary "*" expression, or a pointer type.
-
Stmt
Abstract Type v1.0All statement nodes implement the Stmt interface.
-
End
Method for Stmt v1.0([])
-
Pos
Method for Stmt v1.0([])
-
StructType
Concrete Type v1.0A StructType node represents a struct type.
-
SwitchStmt
Concrete Type v1.0A SwitchStmt node represents an expression switch statement.
-
TypeAssertExpr
Concrete Type v1.0A TypeAssertExpr node represents an expression followed by a
type assertion.
-
TypeSpec
Concrete Type v1.0A TypeSpec node represents a type declaration (TypeSpec production).
-
TypeSwitchStmt
Concrete Type v1.0A TypeSwitchStmt node represents a type switch statement.
-
UnaryExpr
Concrete Type v1.0A UnaryExpr node represents a unary expression.
Unary "*" expressions are represented via StarExpr nodes.
-
ValueSpec
Concrete Type v1.0A ValueSpec node represents a constant or variable declaration
(ConstSpec or VarSpec production).
-
Visitor
Abstract Type v1.0A 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).
-
Visit
Method for Visitor v1.0([node])
-
arrayOfArrayType
Concrete Type v1.0An ArrayType node represents an array or slice type.
-
arrayOfAssignStmt
Concrete Type v1.0An AssignStmt node represents an assignment or
a short variable declaration.
-
arrayOfBadDecl
Concrete Type v1.0A BadDecl node is a placeholder for a declaration containing
syntax errors for which a correct declaration node cannot be
created.
-
arrayOfBadExpr
Concrete Type v1.0A BadExpr node is a placeholder for an expression containing
syntax errors for which a correct expression node cannot be
created.
-
arrayOfBadStmt
Concrete Type v1.0A BadStmt node is a placeholder for statements containing
syntax errors for which no correct statement nodes can be
created.
-
arrayOfBasicLit
Concrete Type v1.0A BasicLit node represents a literal of basic type.
-
arrayOfBinaryExpr
Concrete Type v1.0A BinaryExpr node represents a binary expression.
-
arrayOfBlockStmt
Concrete Type v1.0A BlockStmt node represents a braced statement list.
-
arrayOfBranchStmt
Concrete Type v1.0A BranchStmt node represents a break, continue, goto,
or fallthrough statement.
-
arrayOfCallExpr
Concrete Type v1.0A CallExpr node represents an expression followed by an argument list.
-
arrayOfCaseClause
Concrete Type v1.0A CaseClause represents a case of an expression or type switch statement.
-
arrayOfChanDir
Concrete Type v1.0The direction of a channel type is indicated by a bit
mask including one or both of the following constants.
-
arrayOfChanType
Concrete Type v1.0A ChanType node represents a channel type.
-
arrayOfCommClause
Concrete Type v1.0A CommClause node represents a case of a select statement.
-
arrayOfComment
Concrete Type v1.0A Comment node represents a single //-style or /*-style comment.
The Text field contains the comment text without carriage returns (\r) that
may have been present in the source. Because a comment's end position is
computed using len(Text), the position reported by End() does not match the
true source end position for comments containing carriage returns.
-
arrayOfCommentGroup
Concrete Type v1.0A CommentGroup represents a sequence of comments
with no other tokens and no empty lines between.
-
arrayOfCommentMap
Concrete Type v1.0A CommentMap maps an AST node to a list of comment groups
associated with it. See NewCommentMap for a description of
the association.
-
arrayOfCompositeLit
Concrete Type v1.0A CompositeLit node represents a composite literal.
-
arrayOfDecl
Concrete Type v1.0All declaration nodes implement the Decl interface.
-
arrayOfDeclStmt
Concrete Type v1.0A DeclStmt node represents a declaration in a statement list.
-
arrayOfDeferStmt
Concrete Type v1.0A DeferStmt node represents a defer statement.
-
arrayOfEllipsis
Concrete Type v1.0An Ellipsis node stands for the "..." type in a
parameter list or the "..." length in an array type.
-
arrayOfEmptyStmt
Concrete Type v1.0An EmptyStmt node represents an empty statement.
The "position" of the empty statement is the position
of the immediately following (explicit or implicit) semicolon.
-
arrayOfExpr
Concrete Type v1.0All expression nodes implement the Expr interface.
-
arrayOfExprStmt
Concrete Type v1.0An ExprStmt node represents a (stand-alone) expression
in a statement list.
-
arrayOfField
Concrete Type v1.0A Field represents a Field declaration list in a struct type,
a method list in an interface type, or a parameter/result declaration
in a signature.
Field.Names is nil for unnamed parameters (parameter lists which only contain types)
and embedded struct fields. In the latter case, the field name is the type name.
-
arrayOfFieldFilter
Concrete Type v1.0A FieldFilter may be provided to Fprint to control the output.
-
arrayOfFieldList
Concrete Type v1.0A FieldList represents a list of Fields, enclosed by parentheses,
curly braces, or square brackets.
-
arrayOfFile
Concrete Type v1.0A File node represents a Go source file.
The Comments list contains all comments in the source file in order of
appearance, including the comments that are pointed to from other nodes
via Doc and Comment fields.
For correct printing of source code containing comments (using packages
go/format and go/printer), special care must be taken to update comments
when a File's syntax tree is modified: For printing, comments are interspersed
between tokens based on their position. If syntax tree nodes are
removed or moved, relevant comments in their vicinity must also be removed
(from the File.Comments list) or moved accordingly (by updating their
positions). A CommentMap may be used to facilitate some of these operations.
Whether and how a comment is associated with a node depends on the
interpretation of the syntax tree by the manipulating program: Except for Doc
and Comment comments directly associated with nodes, the remaining comments
are "free-floating" (see also issues #18593, #20744).
-
arrayOfFilter
Concrete Type v1.0 -
arrayOfForStmt
Concrete Type v1.0A ForStmt represents a for statement.
-
arrayOfFuncDecl
Concrete Type v1.0A FuncDecl node represents a function declaration.
-
arrayOfFuncLit
Concrete Type v1.0A FuncLit node represents a function literal.
-
arrayOfFuncType
Concrete Type v1.0A FuncType node represents a function type.
-
arrayOfGenDecl
Concrete Type v1.0A GenDecl node (generic declaration node) represents an import,
constant, type or variable declaration. A valid Lparen position
(Lparen.IsValid()) indicates a parenthesized declaration.
Relationship between Tok value and Specs element type:
token.IMPORT *ImportSpec
token.CONST *ValueSpec
token.TYPE *TypeSpec
token.VAR *ValueSpec
-
arrayOfGoStmt
Concrete Type v1.0A GoStmt node represents a go statement.
-
arrayOfIdent
Concrete Type v1.0An Ident node represents an identifier.
-
arrayOfIfStmt
Concrete Type v1.0An IfStmt node represents an if statement.
-
arrayOfImportSpec
Concrete Type v1.0An ImportSpec node represents a single package import.
-
arrayOfImporter
Concrete Type v1.0An Importer resolves import paths to package Objects.
The imports map records the packages already imported,
indexed by package id (canonical import path).
An Importer must determine the canonical import path and
check the map to see if it is already present in the imports map.
If so, the Importer can return the map entry. Otherwise, the
Importer should load the package data for the given path into
a new *Object (pkg), record pkg in the imports map, and then
return pkg.
-
arrayOfIncDecStmt
Concrete Type v1.0An IncDecStmt node represents an increment or decrement statement.
-
arrayOfIndexExpr
Concrete Type v1.0An IndexExpr node represents an expression followed by an index.
-
arrayOfIndexListExpr
Concrete Type v1.0An IndexListExpr node represents an expression followed by multiple
indices.
-
arrayOfInterfaceType
Concrete Type v1.0An InterfaceType node represents an interface type.
-
arrayOfKeyValueExpr
Concrete Type v1.0A KeyValueExpr node represents (key : value) pairs
in composite literals.
-
arrayOfLabeledStmt
Concrete Type v1.0A LabeledStmt node represents a labeled statement.
-
arrayOfMapType
Concrete Type v1.0A MapType node represents a map type.
-
arrayOfMergeMode
Concrete Type v1.0The MergeMode flags control the behavior of MergePackageFiles.
-
arrayOfNode
Concrete Type v1.0All node types implement the Node interface.
-
arrayOfObjKind
Concrete Type v1.0ObjKind describes what an object represents.
-
arrayOfObject
Concrete Type v1.0An Object describes a named language entity such as a package,
constant, type, variable, function (incl. methods), or label.
The Data fields contains object-specific data:
Kind Data type Data value
Pkg *Scope package scope
Con int iota for the respective declaration
-
arrayOfPackage
Concrete Type v1.0A Package node represents a set of source files
collectively building a Go package.
-
arrayOfParenExpr
Concrete Type v1.0A ParenExpr node represents a parenthesized expression.
-
arrayOfRangeStmt
Concrete Type v1.0A RangeStmt represents a for statement with a range clause.
-
arrayOfReturnStmt
Concrete Type v1.0A ReturnStmt node represents a return statement.
-
arrayOfScope
Concrete Type v1.0A Scope maintains the set of named language entities declared
in the scope and a link to the immediately surrounding (outer)
scope.
-
arrayOfSelectStmt
Concrete Type v1.0A SelectStmt node represents a select statement.
-
arrayOfSelectorExpr
Concrete Type v1.0A SelectorExpr node represents an expression followed by a selector.
-
arrayOfSendStmt
Concrete Type v1.0A SendStmt node represents a send statement.
-
arrayOfSliceExpr
Concrete Type v1.0A SliceExpr node represents an expression followed by slice indices.
-
arrayOfSpec
Concrete Type v1.0The Spec type stands for any of *ImportSpec, *ValueSpec, and *TypeSpec.
-
arrayOfStarExpr
Concrete Type v1.0A StarExpr node represents an expression of the form "*" Expression.
Semantically it could be a unary "*" expression, or a pointer type.
-
arrayOfStmt
Concrete Type v1.0All statement nodes implement the Stmt interface.
-
arrayOfStructType
Concrete Type v1.0A StructType node represents a struct type.
-
arrayOfSwitchStmt
Concrete Type v1.0A SwitchStmt node represents an expression switch statement.
-
arrayOfTypeAssertExpr
Concrete Type v1.0A TypeAssertExpr node represents an expression followed by a
type assertion.
-
arrayOfTypeSpec
Concrete Type v1.0A TypeSpec node represents a type declaration (TypeSpec production).
-
arrayOfTypeSwitchStmt
Concrete Type v1.0A TypeSwitchStmt node represents a type switch statement.
-
arrayOfUnaryExpr
Concrete Type v1.0A UnaryExpr node represents a unary expression.
Unary "*" expressions are represented via StarExpr nodes.
-
arrayOfValueSpec
Concrete Type v1.0A ValueSpec node represents a constant or variable declaration
(ConstSpec or VarSpec production).
-
arrayOfVisitor
Concrete Type v1.0A 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).