ast

package
v0.769.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assign

func Assign(lhs ...Expr) func(op string) func(rhs ...Expr) *AssignStmt

Assign creates an = AssignStmt.

func Case

func Case(list ...Expr) func(stmts ...Stmt) *CaseClause

Case creates a `case x, y, z:` CaseClause.

func ExportedName

func ExportedName(id string) string

func Format

func Format(node fmt.Formatter) []byte

Format formats a node as a snippet of Go source code.

func Init

func Init(idents ...string) func(rhs ...Expr) *AssignStmt

Init creates an := AssignStmt.

func NonExportedName

func NonExportedName(id string) string

func RecvAssignComm

func RecvAssignComm(lhs ...Expr) func(op string) func(ch Expr) func(stmts ...Stmt) *CommClause

RecvAssignComm creates a `case x, y op <-ch:` CommClause.

func RecvInitComm

func RecvInitComm(lhs ...string) func(ch Expr) func(stmts ...Stmt) *CommClause

RecvInitComm creates a `case x, y := <-ch:` CommClause.

Types

type ArrayType

type ArrayType struct {
	Lbrack Token // "["
	Len    Expr  // Ellipsis node for [...]T array types, nil for slice types
	Elt    Expr  // element type
}

ArrayType ...

func ArrayEllipsis

func ArrayEllipsis(elt Expr) *ArrayType

ArrayEllipsis creates a `[...]elt` ArrayType.

func ArrayN

func ArrayN(n int, elt Expr) *ArrayType

ArrayN creates a `[n]elt` ArrayType.

func SliceType

func SliceType(elt Expr) *ArrayType

SliceType creates a `[]elt` ArrayType.

func (*ArrayType) Format

func (n *ArrayType) Format(s fmt.State, c rune)

Format formats an ArrayType as a snippet of Go source code.

func (*ArrayType) GoIsExpr

func (*ArrayType) GoIsExpr()

GoIsExpr ...

type AssignStmt

type AssignStmt struct {
	LHS []Expr
	Tok Token
	RHS []Expr
}

AssignStmt ...

func Append

func Append(slice Expr, elt Expr) *AssignStmt

Append creates an a = append(a, b) statement.

func (*AssignStmt) Format

func (n *AssignStmt) Format(s fmt.State, c rune)

Format formats an AssignStmt as a snippet of Go source code.

func (*AssignStmt) GoIsStmt

func (*AssignStmt) GoIsStmt()

GoIsStmt ...

type BadDecl

type BadDecl struct {
	Token Token
}

BadDecl ...

func (*BadDecl) Format

func (n *BadDecl) Format(s fmt.State, c rune)

Format formats a BadDecl as a snippet of Go source code.

func (*BadDecl) GoIsDecl

func (*BadDecl) GoIsDecl()

GoIsDecl ...

type BadExpr

type BadExpr struct {
	Token Token
}

BadExpr ...

func (*BadExpr) Format

func (n *BadExpr) Format(s fmt.State, c rune)

Format formats a BadExpr as a snippet of Go source code.

func (*BadExpr) GoIsExpr

func (*BadExpr) GoIsExpr()

GoIsExpr ...

type BadStmt

type BadStmt struct {
	Token Token
}

BadStmt ...

func (*BadStmt) Format

func (n *BadStmt) Format(s fmt.State, c rune)

Format formats a BadStmt as a snippet of Go source code.

func (*BadStmt) GoIsStmt

func (*BadStmt) GoIsStmt()

GoIsStmt ...

type BasicLit

type BasicLit struct {
	Token Token
}

BasicLit ...

func Float

func Float(v float64) *BasicLit

Float creates a BasicLit for a float64.

func Int

func Int(v int) *BasicLit

Int creates a BasicLit for an int.

func Lit

func Lit(v interface{}) *BasicLit

Lit creates a BasicLit for an arbitrary type. It should only be used for primitives.

func String

func String(v string) *BasicLit

String creates a BasicLit for a string.

func (*BasicLit) Format

func (n *BasicLit) Format(s fmt.State, c rune)

Format formats a BasicLit as a snippet of Go source code.

func (*BasicLit) GoIsExpr

func (*BasicLit) GoIsExpr()

GoIsExpr ...

type BinaryExpr

type BinaryExpr struct {
	X  Expr
	Op Token
	Y  Expr
}

BinaryExpr ...

func Binary

func Binary(x Expr, op string, y Expr) *BinaryExpr

Binary creates a BinaryExpr.

func (*BinaryExpr) Format

func (n *BinaryExpr) Format(s fmt.State, c rune)

Format formats a BinaryExpr as a snippet of Go source code.

func (*BinaryExpr) GoIsExpr

func (*BinaryExpr) GoIsExpr()

GoIsExpr ...

type BlockStmt

type BlockStmt struct {
	Lbrace Token // "{"
	List   []Stmt
	Rbrace Token // "}"
}

BlockStmt ...

func Block

func Block(stmt ...Stmt) *BlockStmt

Block creates a BlockStmt.

func (*BlockStmt) Format

func (n *BlockStmt) Format(s fmt.State, c rune)

Format formats a BlockStmt as a snippet of Go source code.

func (*BlockStmt) GoIsStmt

func (*BlockStmt) GoIsStmt()

GoIsStmt ...

type BranchStmt

type BranchStmt struct {
	Tok   Token  // keyword token (BREAK, CONTINUE, GOTO, FALLTHROUGH)
	Label *Ident // label name; or nil
}

BranchStmt ...

func Break

func Break() *BranchStmt

Break creates a `break` BranchStmt.

func BreakTo

func BreakTo(label string) *BranchStmt

BreakTo creates a `break label` BranchStmt.

func Continue

func Continue() *BranchStmt

Continue creates a `continue` BranchStmt.

func ContinueTo

func ContinueTo(label string) *BranchStmt

ContinueTo creates a `continue label` BranchStmt.

func Fallthrough

func Fallthrough() *BranchStmt

Fallthrough creates a `fallthrough` BranchStmt.

func Goto

func Goto(label string) *BranchStmt

Goto creates a `goto label` BranchStmt.

func (*BranchStmt) Format

func (n *BranchStmt) Format(s fmt.State, c rune)

Format formats a BranchStmt as a snippet of Go source code.

func (*BranchStmt) GoIsStmt

func (*BranchStmt) GoIsStmt()

GoIsStmt ...

type CallExpr

type CallExpr struct {
	Fun      Expr   // function expression
	Lparen   Token  // "("
	Args     []Expr // function arguments; or nil
	Ellipsis Token  // "..." (token.NoPos if there is no "...")
	Rparen   Token  // ")"
}

CallExpr ...

func Call

func Call(fun Expr, args ...Expr) *CallExpr

Call creates a CallExpr.

func CallVararg

func CallVararg(fun Expr, args ...Expr) *CallExpr

CallVararg creates an `arg...` CallStmt.

func (*CallExpr) Format

func (n *CallExpr) Format(s fmt.State, c rune)

Format formats a CallExpr as a snippet of Go source code.

func (*CallExpr) GoIsExpr

func (*CallExpr) GoIsExpr()

GoIsExpr ...

type CaseClause

type CaseClause struct {
	Case  Token  // "case" or "default" keyword
	List  []Expr // list of expressions or types; nil means default case
	Colon Token
	Body  []Stmt // statement list; or nil
}

CaseClause ...

func DefaultCase

func DefaultCase(stmts ...Stmt) *CaseClause

DefaultCase creates a `default:` CaseClause.

func (*CaseClause) Format

func (n *CaseClause) Format(s fmt.State, c rune)

Format formats a CaseClause as a snippet of Go source code.

func (*CaseClause) GoIsStmt

func (*CaseClause) GoIsStmt()

GoIsStmt ...

type ChanType

type ChanType struct {
	Begin Token // "chan" keyword or "<-" (whichever comes first)
	Arrow Token // "<-" (token.NoPos if there is no "<-"); added in Go 1.1
	// Dir         {|"SEND", "RECV"|} powerset without {||}
	Dir   string
	Value Expr // value type
}

ChanType ...

func (*ChanType) Format

func (n *ChanType) Format(s fmt.State, c rune)

Format formats a ChanType as a snippet of Go source code.

func (*ChanType) GoIsExpr

func (*ChanType) GoIsExpr()

GoIsExpr ...

type CommClause

type CommClause struct {
	Case  Token  // "case" or "default" keyword
	Comm  Stmt   // send or receive statement; nil means default case
	Colon Token  // ":"
	Body  []Stmt // statement list; or nil
}

CommClause ...

func DefaultComm

func DefaultComm(stmts ...Stmt) *CommClause

DefaultComm creates a `default:` CommClause.

func SendComm

func SendComm(ch, value Expr, stmts ...Stmt) *CommClause

SendComm creates a `case ch <- value:` CommClause.

func (*CommClause) Format

func (n *CommClause) Format(s fmt.State, c rune)

Format formats a CommClause as a snippet of Go source code.

func (*CommClause) GoIsStmt

func (*CommClause) GoIsStmt()

GoIsStmt ...

type Comment

type Comment struct {
	Token Token
}

Comment ...

func Commentf

func Commentf(format string, args ...interface{}) Comment

Commentf creates a Comment from a string, adding "// " in front.

func (*Comment) Format

func (n *Comment) Format(s fmt.State, c rune)

Format formats a Comment as a snippet of Go source code.

type CommentGroup

type CommentGroup struct {
	List []Comment // len(List) > 0
}

CommentGroup ...

func Comments

func Comments(lines ...Comment) *CommentGroup

Comments create a CommentGroup from lines.

func (*CommentGroup) Format

func (n *CommentGroup) Format(s fmt.State, c rune)

Format formats a CommentGroup as a snippet of Go source code.

type CompositeLit

type CompositeLit struct {
	Type       Expr   // literal type; or nil
	Lbrace     Token  // "{"
	Elts       []Expr // list of composite elements; or nil
	Rbrace     Token  // "}"
	Incomplete bool   // true if (source) expressions are missing in the Elts list; added in Go 1.11
}

CompositeLit ...

func Composite

func Composite(t Expr, elts ...Expr) *CompositeLit

Composite creates a CompositeLit.

func (*CompositeLit) Format

func (n *CompositeLit) Format(s fmt.State, c rune)

Format formats a CompositeLit as a snippet of Go source code.

func (*CompositeLit) GoIsExpr

func (*CompositeLit) GoIsExpr()

GoIsExpr ...

type Decl

type Decl interface {
	fmt.Formatter
	GoIsDecl()
}

Decl ...

type DeclStmt

type DeclStmt struct {
	Decl Decl // GenDecl with CONST, TYPE, or VAR token
}

DeclStmt ...

func (*DeclStmt) Format

func (n *DeclStmt) Format(s fmt.State, c rune)

Format formats a DeclStmt as a snippet of Go source code.

func (*DeclStmt) GoIsStmt

func (*DeclStmt) GoIsStmt()

GoIsStmt ...

type DeferStmt

type DeferStmt struct {
	Defer Token // "defer" keyword
	Call  CallExpr
}

DeferStmt ...

func Defer

func Defer(fun Expr, args ...Expr) *DeferStmt

Defer creates a DeferStmt.

func DeferVararg

func DeferVararg(fun Expr, args ...Expr) *DeferStmt

DeferVararg creates an `arg...` DeferStmt.

func (*DeferStmt) Format

func (n *DeferStmt) Format(s fmt.State, c rune)

Format formats a DeferStmt as a snippet of Go source code.

func (*DeferStmt) GoIsStmt

func (*DeferStmt) GoIsStmt()

GoIsStmt ...

type Ellipsis

type Ellipsis struct {
	Ellipsis Token // "..."
	Elt      Expr  // ellipsis element type (parameter lists only); or nil
}

Ellipsis ...

func (*Ellipsis) Format

func (n *Ellipsis) Format(s fmt.State, c rune)

Format formats an Ellipsis as a snippet of Go source code.

func (*Ellipsis) GoIsExpr

func (*Ellipsis) GoIsExpr()

GoIsExpr ...

type EmptyStmt

type EmptyStmt struct {
	Semicolon Token // following ";"
	Implicit  bool  // if set, ";" was omitted in the source; added in Go 1.5
}

EmptyStmt ...

func (*EmptyStmt) Format

func (n *EmptyStmt) Format(s fmt.State, c rune)

Format formats an EmptyStmt as a snippet of Go source code.

func (*EmptyStmt) GoIsStmt

func (*EmptyStmt) GoIsStmt()

GoIsStmt ...

type Expr

type Expr interface {
	fmt.Formatter
	GoIsExpr()
}

Expr ...

type ExprStmt

type ExprStmt struct {
	X Expr // expression
}

ExprStmt ...

func CallStmt

func CallStmt(fun Expr, args ...Expr) *ExprStmt

Call creates a Call ExprStmt.

func (*ExprStmt) Format

func (n *ExprStmt) Format(s fmt.State, c rune)

Format formats an ExprStmt as a snippet of Go source code.

func (*ExprStmt) GoIsStmt

func (*ExprStmt) GoIsStmt()

GoIsStmt ...

type Field

type Field struct {
	Doc     *CommentGroup // associated documentation; or nil
	Names   []Ident       // field/method/parameter names; or nil
	Type    Expr          // field/method/parameter type
	Tag     *BasicLit     // field tag; or nil
	Comment *CommentGroup // line comments; or nil
}

Field ...

func (*Field) Format

func (n *Field) Format(s fmt.State, c rune)

Format formats a Field as a snippet of Go source code.

func (Field) WithDoc

func (n Field) WithDoc(comments ...Comment) *Field

type FieldList

type FieldList struct {
	Opening Token   // opening parenthesis/brace, if any
	List    []Field // field list; or nil
	Closing Token   // closing parenthesis/brace, if any
}

FieldList ...

func Fields

func Fields(fields ...Field) *FieldList

Fields creates a FieldList.

func (*FieldList) Format

func (n *FieldList) Format(s fmt.State, c rune)

Format formats a FieldList as a snippet of Go source code.

func (FieldList) Parens

func (n FieldList) Parens() *FieldList

Parens adds "(" and ")" opening and closing to a FieldList.

type File

type File struct {
	Doc        *CommentGroup  // associated documentation; or nil
	Package    Token          // "package" keyword
	Name       Ident          // package name
	Decls      []Decl         // top-level declarations; or nil
	Imports    []ImportSpec   // imports in this file
	Unresolved []Ident        // unresolved identifiers in this file
	Comments   []CommentGroup // list of all comments in the source file
}

File ...

func (*File) Format

func (n *File) Format(s fmt.State, c rune)

Format formats a File as a snippet of Go source code.

func (File) WithDoc

func (n File) WithDoc(comments ...Comment) *File

type ForStmt

type ForStmt struct {
	For  Token // "for" keyword
	Init Stmt  // initialization statement; or nil
	Cond Expr  // condition; or nil
	Post Stmt  // post iteration statement; or nil
	Body BlockStmt
}

ForStmt ...

func (*ForStmt) Format

func (n *ForStmt) Format(s fmt.State, c rune)

Format formats a ForStmt as a snippet of Go source code.

func (*ForStmt) GoIsStmt

func (*ForStmt) GoIsStmt()

GoIsStmt ...

type FuncDecl

type FuncDecl struct {
	Doc  *CommentGroup // associated documentation; or nil
	Recv *FieldList    // receiver (methods); or nil (functions)
	Name Ident         // function/method name
	Type FuncType      // function signature: parameters, results, and "func" keyword
	Body *BlockStmt    // function body; or nil for external (non-Go) function
}

FuncDecl ...

func FuncD

func FuncD(name string, params FieldList, results *FieldList, stmts ...Stmt) *FuncDecl

FuncD creates a FuncDecl.

func (*FuncDecl) Format

func (n *FuncDecl) Format(s fmt.State, c rune)

Format formats a FuncDecl as a snippet of Go source code.

func (*FuncDecl) GoIsDecl

func (*FuncDecl) GoIsDecl()

GoIsDecl ...

func (FuncDecl) WithDoc

func (n FuncDecl) WithDoc(comments ...Comment) *FuncDecl

type FuncLit

type FuncLit struct {
	Type FuncType  // function type
	Body BlockStmt // function body
}

FuncLit ...

func Func

func Func(params FieldList, results *FieldList, stmts ...Stmt) *FuncLit

Func creates a FuncLit.

func FuncT

func FuncT(t FuncType, stmts ...Stmt) *FuncLit

FuncT creates a FuncLit from a FuncType and a body.

func (*FuncLit) Format

func (n *FuncLit) Format(s fmt.State, c rune)

Format formats a FuncLit as a snippet of Go source code.

func (*FuncLit) GoIsExpr

func (*FuncLit) GoIsExpr()

GoIsExpr ...

type FuncType

type FuncType struct {
	Func    Token      // "func" keyword (token.NoPos if there is no "func")
	Params  FieldList  // (incoming) parameters; non-nil
	Results *FieldList // (outgoing) results; or nil
}

FuncType ...

func (*FuncType) Format

func (n *FuncType) Format(s fmt.State, c rune)

Format formats a FuncType as a snippet of Go source code.

func (*FuncType) GoIsExpr

func (*FuncType) GoIsExpr()

GoIsExpr ...

type GenDecl

type GenDecl struct {
	Doc    *CommentGroup // associated documentation; or nil
	Tok    Token         // IMPORT, CONST, TYPE, VAR
	Lparen Token         // '(', if any
	Specs  []Spec
	Rparen Token // ')', if any
}

GenDecl ...

func Const

func Const(values ...ValueSpec) *GenDecl

Const creates a `const` GenDecl.

func Import

func Import(imports ...ImportSpec) *GenDecl

Import creates an `import` GenDecl.

func Types

func Types(types ...TypeSpec) *GenDecl

Types creates a `type` GenDecl.

func Var

func Var(values ...ValueSpec) *GenDecl

Var creates a `var` GenDecl.

func (*GenDecl) Format

func (n *GenDecl) Format(s fmt.State, c rune)

Format formats a GenDecl as a snippet of Go source code.

func (*GenDecl) GoIsDecl

func (*GenDecl) GoIsDecl()

GoIsDecl ...

func (GenDecl) WithDoc

func (n GenDecl) WithDoc(comments ...Comment) *GenDecl

type GoStmt

type GoStmt struct {
	Go   Token // "go" keyword
	Call CallExpr
}

GoStmt ...

func (*GoStmt) Format

func (n *GoStmt) Format(s fmt.State, c rune)

Format formats a GoStmt as a snippet of Go source code.

func (*GoStmt) GoIsStmt

func (*GoStmt) GoIsStmt()

GoIsStmt ...

type Ident

type Ident struct {
	Name Token // identifier name
}

Ident ...

func ExportedID

func ExportedID(id string) *Ident

func I

func I(id string) *Ident

I creates an Ident.

func Idents

func Idents(ids ...string) []Ident

Idents creates an []Ident from ids.

func Iota

func Iota() *Ident

Iota creates an iota reference.

func Nil

func Nil() *Ident

Nil creates a `nil` Ident.

func NonExportedID

func NonExportedID(id string) *Ident

func (*Ident) Format

func (n *Ident) Format(s fmt.State, c rune)

Format formats an Ident as a snippet of Go source code.

func (*Ident) GoIsExpr

func (*Ident) GoIsExpr()

GoIsExpr ...

type IfStmt

type IfStmt struct {
	If   Token // "if" keyword
	Init Stmt  // initialization statement; or nil
	Cond Expr  // condition
	Body BlockStmt
	Else Stmt // else branch; or nil
}

IfStmt ...

func If

func If(init Stmt, cond Expr, stmts ...Stmt) *IfStmt

If creates an IfStmt.

func (*IfStmt) CopyChain

func (n *IfStmt) CopyChain() (head, last *IfStmt)

CopyChain copies an IfStmt and, recursively, n.Else if it is an IfStmt. Returns the copy and the last node in the chain.

func (*IfStmt) Format

func (n *IfStmt) Format(s fmt.State, c rune)

Format formats an IfStmt as a snippet of Go source code.

func (*IfStmt) GoIsStmt

func (*IfStmt) GoIsStmt()

GoIsStmt ...

func (*IfStmt) WithElse

func (n *IfStmt) WithElse(stmts ...Stmt) *IfStmt

WithElse creates a copy of IfStmt with an Else stmt added.

func (*IfStmt) WithElseIf

func (n *IfStmt) WithElseIf(init Stmt, cond Expr, stmts ...Stmt) *IfStmt

WithElseIf creates a copy of IfStmt with an Else stmt added.

type ImportSpec

type ImportSpec struct {
	Doc     *CommentGroup // associated documentation; or nil
	Name    *Ident        // local package name (including "."); or nil
	Path    BasicLit      // import path
	Comment *CommentGroup // line comments; or nil
	EndPos  Token         // end of spec (overrides Path.Pos if nonzero)
}

ImportSpec ...

func ImportGroups

func ImportGroups(specs ...[]ImportSpec) []ImportSpec

func Imports

func Imports(imports ...string) []ImportSpec

func (*ImportSpec) Format

func (n *ImportSpec) Format(s fmt.State, c rune)

Format formats an ImportSpec as a snippet of Go source code.

func (*ImportSpec) GoIsSpec

func (*ImportSpec) GoIsSpec()

GoIsSpec ...

func (ImportSpec) WithDoc

func (n ImportSpec) WithDoc(comments ...Comment) *ImportSpec

type IncDecStmt

type IncDecStmt struct {
	X   Expr
	Tok Token
}

IncDecStmt ...

func Dec

func Dec(x Expr) *IncDecStmt

Dec creates an `x--` IncDecStmt.

func Inc

func Inc(x Expr) *IncDecStmt

Inc creates an `x++` IncDecStmt.

func (*IncDecStmt) Format

func (n *IncDecStmt) Format(s fmt.State, c rune)

Format formats an IncDecStmt as a snippet of Go source code.

func (*IncDecStmt) GoIsStmt

func (*IncDecStmt) GoIsStmt()

GoIsStmt ...

type IndexExpr

type IndexExpr struct {
	X      Expr
	Lbrack Token // "["
	Index  Expr
	Rbrack Token // "]"
}

IndexExpr ...

func Index

func Index(a, b Expr) *IndexExpr

Index creates an IndexExpr.

func (*IndexExpr) Format

func (n *IndexExpr) Format(s fmt.State, c rune)

Format formats an IndexExpr as a snippet of Go source code.

func (*IndexExpr) GoIsExpr

func (*IndexExpr) GoIsExpr()

GoIsExpr ...

type InterfaceType

type InterfaceType struct {
	Interface  Token     // "interface" keyword
	Methods    FieldList // list of methods
	Incomplete bool      // true if (source) methods are missing in the Methods list
}

InterfaceType ...

func (*InterfaceType) Format

func (n *InterfaceType) Format(s fmt.State, c rune)

Format formats an InterfaceType as a snippet of Go source code.

func (*InterfaceType) GoIsExpr

func (*InterfaceType) GoIsExpr()

GoIsExpr ...

type KeyValueExpr

type KeyValueExpr struct {
	Key   Expr
	Colon Token
	Value Expr
}

KeyValueExpr ...

func KV

func KV(key, value Expr) *KeyValueExpr

KV creates a KeyValueExpr

func (*KeyValueExpr) Format

func (n *KeyValueExpr) Format(s fmt.State, c rune)

Format formats a KeyValueExpr as a snippet of Go source code.

func (*KeyValueExpr) GoIsExpr

func (*KeyValueExpr) GoIsExpr()

GoIsExpr ...

type LabeledStmt

type LabeledStmt struct {
	Label Ident
	Colon Token
	Stmt  Stmt
}

LabeledStmt ...

func (*LabeledStmt) Format

func (n *LabeledStmt) Format(s fmt.State, c rune)

Format formats a LabeledStmt as a snippet of Go source code.

func (*LabeledStmt) GoIsStmt

func (*LabeledStmt) GoIsStmt()

GoIsStmt ...

type MapType

type MapType struct {
	Map   Token // "map" keyword
	Key   Expr
	Value Expr
}

MapType ...

func Map

func Map(key, value Expr) *MapType

Map creates a MapType.

func (*MapType) Format

func (n *MapType) Format(s fmt.State, c rune)

Format formats a MapType as a snippet of Go source code.

func (*MapType) GoIsExpr

func (*MapType) GoIsExpr()

GoIsExpr ...

type NoCommaSepFieldList

type NoCommaSepFieldList FieldList

NoCommaSepFieldList ...

func (*NoCommaSepFieldList) Format

func (n *NoCommaSepFieldList) Format(s fmt.State, c rune)

Format ...

type ParenExpr

type ParenExpr struct {
	Lparen Token // "("
	X      Expr  // parenthesized expression
	Rparen Token // ")"
}

ParenExpr ...

func (*ParenExpr) Format

func (n *ParenExpr) Format(s fmt.State, c rune)

Format formats a ParenExpr as a snippet of Go source code.

func (*ParenExpr) GoIsExpr

func (*ParenExpr) GoIsExpr()

GoIsExpr ...

type RangeStmt

type RangeStmt struct {
	For   Token // "for" keyword
	Key   Expr  // Key may be nil
	Value Expr  // Value may be nil
	Tok   Token // invalid if Key == nil
	X     Expr  // value to range over
	Body  BlockStmt
}

RangeStmt ...

func Range

func Range(key, value Expr, tok string, x Expr, body ...Stmt) *RangeStmt

Range creates a RangeStmt.

func (*RangeStmt) Format

func (n *RangeStmt) Format(s fmt.State, c rune)

Format formats a RangeStmt as a snippet of Go source code.

func (*RangeStmt) GoIsStmt

func (*RangeStmt) GoIsStmt()

GoIsStmt ...

type ReturnStmt

type ReturnStmt struct {
	Return  Token  // "return" keyword
	Results []Expr // result expressions; or nil
}

ReturnStmt ...

func Return

func Return(results ...Expr) *ReturnStmt

Return creates a ReturnStmt.

func (*ReturnStmt) Format

func (n *ReturnStmt) Format(s fmt.State, c rune)

Format formats a ReturnStmt as a snippet of Go source code.

func (*ReturnStmt) GoIsStmt

func (*ReturnStmt) GoIsStmt()

GoIsStmt ...

type SelectStmt

type SelectStmt struct {
	Select Token     // "select" keyword
	Body   BlockStmt // CommClauses only
}

SelectStmt ...

func Select

func Select(body ...Stmt) *SelectStmt

Select creates a SelectStmt.

func (*SelectStmt) Format

func (n *SelectStmt) Format(s fmt.State, c rune)

Format formats a SelectStmt as a snippet of Go source code.

func (*SelectStmt) GoIsStmt

func (*SelectStmt) GoIsStmt()

GoIsStmt ...

type SelectorExpr

type SelectorExpr struct {
	X   Expr  // expression
	Sel Ident // field selector
}

SelectorExpr ...

func Dot

func Dot(x Expr, id string, ids ...string) *SelectorExpr

Dot creates a SelectorExpr.

func (*SelectorExpr) Format

func (n *SelectorExpr) Format(s fmt.State, c rune)

Format formats a SelectorExpr as a snippet of Go source code.

func (*SelectorExpr) GoIsExpr

func (*SelectorExpr) GoIsExpr()

GoIsExpr ...

type SendStmt

type SendStmt struct {
	Chan  Expr
	Arrow Token // "<-"
	Value Expr
}

SendStmt ...

func Send

func Send(ch, value Expr) *SendStmt

Send creates a SendStmt.

func (*SendStmt) Format

func (n *SendStmt) Format(s fmt.State, c rune)

Format formats a SendStmt as a snippet of Go source code.

func (*SendStmt) GoIsStmt

func (*SendStmt) GoIsStmt()

GoIsStmt ...

type SliceExpr

type SliceExpr struct {
	X      Expr  // expression
	Lbrack Token // "["
	Low    Expr  // begin of slice range; or nil
	High   Expr  // end of slice range; or nil
	Max    Expr  // maximum capacity of slice; or nil; added in Go 1.2
	Slice3 bool  // true if 3-index slice (2 colons present); added in Go 1.2
	Rbrack Token // "]"
}

SliceExpr ...

func Slice

func Slice(x Expr, args ...Expr) *SliceExpr

Slice creates a SliceExpr.

func (*SliceExpr) Format

func (n *SliceExpr) Format(s fmt.State, c rune)

Format formats a SliceExpr as a snippet of Go source code.

func (*SliceExpr) GoIsExpr

func (*SliceExpr) GoIsExpr()

GoIsExpr ...

type Spec

type Spec interface {
	fmt.Formatter
	GoIsSpec()
}

Spec ...

type StarExpr

type StarExpr struct {
	Star Token // "*"
	X    Expr  // operand
}

StarExpr ...

func Star

func Star(x Expr) *StarExpr

Star creates a StarExpr.

func (*StarExpr) Format

func (n *StarExpr) Format(s fmt.State, c rune)

Format formats a StarExpr as a snippet of Go source code.

func (*StarExpr) GoIsExpr

func (*StarExpr) GoIsExpr()

GoIsExpr ...

type Stmt

type Stmt interface {
	fmt.Formatter
	GoIsStmt()
}

Stmt ...

func Panic

func Panic(expr Expr) Stmt

type StructType

type StructType struct {
	Struct     Token     // "struct" keyword
	Fields     FieldList // list of field declarations
	Incomplete bool      // true if (source) fields are missing in the Fields list
}

StructType ...

func Struct

func Struct(fields ...Field) *StructType

Struct creates a StructType.

func (*StructType) Format

func (n *StructType) Format(s fmt.State, c rune)

Format formats a StructType as a snippet of Go source code.

func (*StructType) GoIsExpr

func (*StructType) GoIsExpr()

GoIsExpr ...

type SwitchStmt

type SwitchStmt struct {
	Switch Token     // "switch" keyword
	Init   Stmt      // initialization statement; or nil
	Tag    Expr      // tag expression; or nil
	Body   BlockStmt // CaseClauses only
}

SwitchStmt ...

func Switch

func Switch(init Expr, body ...Stmt) *SwitchStmt

Switch creates a SwitchStmt.

func (*SwitchStmt) Format

func (n *SwitchStmt) Format(s fmt.State, c rune)

Format formats a SwitchStmt as a snippet of Go source code.

func (*SwitchStmt) GoIsStmt

func (*SwitchStmt) GoIsStmt()

GoIsStmt ...

type Token

type Token struct {
	Kind string
	// Text SliceOfString
	Text string
}

Token ...

func T

func T(text string) *Token

T creates a Token.

func (*Token) Format

func (n *Token) Format(s fmt.State, c rune)

Format formats a Token as a snippet of Go source code.

type TypeAssertExpr

type TypeAssertExpr struct {
	X      Expr  // expression
	Lparen Token // "("; added in Go 1.2
	Type   Expr  // asserted type; nil means type switch X.(type)
	Rparen Token // ")"; added in Go 1.2
}

TypeAssertExpr ...

func Assert

func Assert(x, t Expr) *TypeAssertExpr

Assert creates a TypeAssertExpr.

func AssertType

func AssertType(x Expr) *TypeAssertExpr

AssertType creates a TypeAssertExpr.

func (*TypeAssertExpr) Format

func (n *TypeAssertExpr) Format(s fmt.State, c rune)

Format formats a TypeAssertExpr as a snippet of Go source code.

func (*TypeAssertExpr) GoIsExpr

func (*TypeAssertExpr) GoIsExpr()

GoIsExpr ...

type TypeSpec

type TypeSpec struct {
	Doc     *CommentGroup // associated documentation; or nil
	Name    Ident         // type name
	Assign  Token         // '=', if any; added in Go 1.9
	Type    Expr          // Ident, ParenExpr, SelectorExpr, StarExpr, or any of the XxxTypes
	Comment *CommentGroup // line comments; or nil
}

TypeSpec ...

func (*TypeSpec) Format

func (n *TypeSpec) Format(s fmt.State, c rune)

Format formats a TypeSpec as a snippet of Go source code.

func (*TypeSpec) GoIsSpec

func (*TypeSpec) GoIsSpec()

GoIsSpec ...

func (TypeSpec) WithDoc

func (n TypeSpec) WithDoc(comments ...Comment) *TypeSpec

type TypeSwitchStmt

type TypeSwitchStmt struct {
	Switch Token     // "switch" keyword
	Init   Stmt      // initialization statement; or nil
	Assign Stmt      // x := y.(type) or y.(type)
	Body   BlockStmt // CaseClauses only
}

TypeSwitchStmt ...

func TypeSwitch

func TypeSwitch(init Stmt, x string, y Expr, body ...Stmt) *TypeSwitchStmt

TypeSwitch creates a TypeSwitchStmt.

func (*TypeSwitchStmt) Format

func (n *TypeSwitchStmt) Format(s fmt.State, c rune)

Format formats a TypeSwitchStmt as a snippet of Go source code.

func (*TypeSwitchStmt) GoIsStmt

func (*TypeSwitchStmt) GoIsStmt()

GoIsStmt ...

type UnaryExpr

type UnaryExpr struct {
	Op Token
	X  Expr
}

UnaryExpr ...

func AddrOf

func AddrOf(x Expr) *UnaryExpr

Addr creates an &Expr expression.

func Recv

func Recv(ch Expr) *UnaryExpr

Recv creates a `<-ch` UnaryExpr.

func Unary

func Unary(op string, x Expr) *UnaryExpr

Unary creates a UnaryExpr.

func (*UnaryExpr) Format

func (n *UnaryExpr) Format(s fmt.State, c rune)

Format formats an UnaryExpr as a snippet of Go source code.

func (*UnaryExpr) GoIsExpr

func (*UnaryExpr) GoIsExpr()

GoIsExpr ...

type ValueSpec

type ValueSpec struct {
	Doc     *CommentGroup // associated documentation; or nil
	Names   []Ident       // value names (len(Names) > 0)
	Type    Expr          // value type; or nil
	Values  []Expr        // initial values; or nil
	Comment *CommentGroup // line comments; or nil
}

ValueSpec ...

func (*ValueSpec) Format

func (n *ValueSpec) Format(s fmt.State, c rune)

Format formats a ValueSpec as a snippet of Go source code.

func (*ValueSpec) GoIsSpec

func (*ValueSpec) GoIsSpec()

GoIsSpec ...

func (ValueSpec) WithDoc

func (n ValueSpec) WithDoc(comments ...Comment) *ValueSpec

Jump to

Keyboard shortcuts

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