Documentation
¶
Index ¶
- Constants
- func AddImportForcely(root *dst.File, paths ...string) *dst.GenDecl
- func AddStructField(decl dst.Decl, name string, typ string)
- func AddressOf(name string) *dst.UnaryExpr
- func ArrayType(elem dst.Expr) *dst.ArrayType
- func AssignStmt(lhs, rhs dst.Expr) *dst.AssignStmt
- func Block(stmt dst.Stmt) *dst.BlockStmt
- func BlockStmts(stmts ...dst.Stmt) *dst.BlockStmt
- func BoolFalse() *dst.BasicLit
- func BoolTrue() *dst.BasicLit
- func CallTo(name string, typeArgs *dst.FieldList, args []dst.Expr) *dst.CallExpr
- func CloneTypeParams(typeParams *dst.FieldList) *dst.FieldList
- func CompositeLit(t dst.Expr, elts []dst.Expr) *dst.CompositeLit
- func DeferStmt(call *dst.CallExpr) *dst.DeferStmt
- func DefineStmts(lhs, rhs []dst.Expr) *dst.AssignStmt
- func DereferenceOf(expr dst.Expr) dst.Expr
- func Ellipsis(elt dst.Expr) *dst.Ellipsis
- func EmptyStmt() *dst.EmptyStmt
- func ExprStmt(expr dst.Expr) *dst.ExprStmt
- func Exprs(exprs ...dst.Expr) []dst.Expr
- func FindFuncDecl(root *dst.File, function string, receiverType string) []*dst.FuncDecl
- func FindFuncDeclWithoutRecv(root *dst.File, funcName string) *dst.FuncDecl
- func FindImport(root *dst.File, path string) *dst.ImportSpec
- func FindStructDecl(root *dst.File, structName string) *dst.GenDecl
- func HasReceiver(fn *dst.FuncDecl) bool
- func Ident(name string) *dst.Ident
- func IfNotNilStmt(cond dst.Expr, body, elseBody *dst.BlockStmt) *dst.IfStmt
- func IfStmt(init dst.Stmt, cond dst.Expr, body, elseBody *dst.BlockStmt) *dst.IfStmt
- func IndexExpr(x dst.Expr, index dst.Expr) *dst.IndexExpr
- func IndexListExpr(x dst.Expr, indices []dst.Expr) *dst.IndexListExpr
- func IntLit(value int) *dst.BasicLit
- func InterfaceType() *dst.InterfaceType
- func IsEllipsis(typ dst.Expr) bool
- func IsInterfaceType(typ dst.Expr) bool
- func IsStringLit(expr dst.Expr, val string) bool
- func IsUnusedIdent(ident *dst.Ident) bool
- func KeyValueExpr(key string, value dst.Expr) *dst.KeyValueExpr
- func ListFuncDecls(root *dst.File) []*dst.FuncDecl
- func MakeUnusedIdent(ident *dst.Ident) *dst.Ident
- func NewField(name string, typ dst.Expr) *dst.Field
- func NewVarDecl(name string, paramTypes *dst.FieldList) *dst.GenDecl
- func Nil() dst.Expr
- func ParenExpr(x dst.Expr) *dst.ParenExpr
- func ParseFile(filePath string) (*dst.File, error)
- func ParseFileFast(filePath string) (*dst.File, error)
- func ParseFileOnlyPackage(filePath string) (*dst.File, error)
- func RemoveImport(root *dst.File, path string) *dst.ImportSpec
- func ReturnStmt(results []dst.Expr) *dst.ReturnStmt
- func SelectorExpr(x dst.Expr, sel string) *dst.SelectorExpr
- func SplitMultiNameFields(fieldList *dst.FieldList) *dst.FieldList
- func Stmts(stmts ...dst.Stmt) []dst.Stmt
- func StringLit(value string) *dst.BasicLit
- func StructLit(typeName string, fields ...*dst.KeyValueExpr) dst.Expr
- func SwitchCase(list []dst.Expr, stmts []dst.Stmt) *dst.CaseClause
- func TypeAssertExpr(x dst.Expr, typ dst.Expr) *dst.TypeAssertExpr
- func WriteFile(astRoot *dst.File, filePath string) (string, error)
- type AstParser
Constants ¶
View Source
const ( IdentNil = "nil" IdentTrue = "true" IdentFalse = "false" IdentIgnore = "_" )
Variables ¶
This section is empty.
Functions ¶
func AssignStmt ¶
func AssignStmt(lhs, rhs dst.Expr) *dst.AssignStmt
func CallTo ¶
CallTo creates a call expression to a function with optional type arguments for generics. For non-generic functions (typeArgs is nil or empty), creates a simple call: Foo(args...) For generic functions with type arguments, creates: Foo[T1, T2](args...)
func CloneTypeParams ¶
CloneTypeParams safely clones a type parameter field list for generic functions. Returns nil if the input is nil.
func CompositeLit ¶
func DefineStmts ¶
func DefineStmts(lhs, rhs []dst.Expr) *dst.AssignStmt
func FindFuncDecl ¶
func FindFuncDeclWithoutRecv ¶
func FindImport ¶
func FindImport(root *dst.File, path string) *dst.ImportSpec
func HasReceiver ¶
func IndexListExpr ¶
func InterfaceType ¶
func InterfaceType() *dst.InterfaceType
func IsEllipsis ¶
func IsInterfaceType ¶
func IsUnusedIdent ¶
func KeyValueExpr ¶
func KeyValueExpr(key string, value dst.Expr) *dst.KeyValueExpr
func RemoveImport ¶
func RemoveImport(root *dst.File, path string) *dst.ImportSpec
func ReturnStmt ¶
func ReturnStmt(results []dst.Expr) *dst.ReturnStmt
func SelectorExpr ¶
func SelectorExpr(x dst.Expr, sel string) *dst.SelectorExpr
func SplitMultiNameFields ¶
SplitMultiNameFields splits fields that have multiple names into separate fields. For example, a field like "a, b int" becomes two fields: "a int" and "b int".
func SwitchCase ¶
func TypeAssertExpr ¶
Types ¶
type AstParser ¶
type AstParser struct {
// contains filtered or unexported fields
}
func NewAstParser ¶
func NewAstParser() *AstParser
func (*AstParser) ParseSnippet ¶
ParseSnippet parses the AST from incomplete source code snippet.
Click to show internal directories.
Click to hide internal directories.