Documentation ¶
Index ¶
- func BasicLit(value string) *ast.BasicLit
- func Ident(value string) *ast.Ident
- func IdentList(value ...string) []*ast.Ident
- func IdentListExpr(value ...string) []ast.Expr
- func IntLit(value int) *ast.BasicLit
- func LastExpr(data *References, expr ast.Expr) ast.Expr
- func NewFilename(file string, suffix string) string
- func StringLit(value string) *ast.BasicLit
- type ExprBlockBuilder
- type ExprBuilder
- func (b *ExprBuilder) BinaryExpr(exp ast.Expr, op token.Token) *ExprBuilder
- func (b *ExprBuilder) Call(exp *ExprBuilder) *ast.CallExpr
- func (b *ExprBuilder) CallExpr(args ...ast.Expr) *ast.CallExpr
- func (b *ExprBuilder) CallExprBlock(expr *ExprBlockBuilder) *ast.CallExpr
- func (b *ExprBuilder) CallStr(args ...string) *ast.CallExpr
- func (b *ExprBuilder) CompositeLit(elts *ExprBlockBuilder) *ExprBuilder
- func (b *ExprBuilder) E() ast.Expr
- func (b *ExprBuilder) ExprList() []ast.Expr
- func (b *ExprBuilder) Field(names []*ast.Ident) *ast.Field
- func (b *ExprBuilder) KeyValue(value *ExprBuilder) *ExprBuilder
- func (b *ExprBuilder) NotEquals(expr *ExprBuilder) *ExprBuilder
- func (b *ExprBuilder) NotEqualsExpr(expr ast.Expr) *ExprBuilder
- func (b *ExprBuilder) NotNil() *ExprBuilder
- func (b *ExprBuilder) Property(property string) *ExprBuilder
- func (b *ExprBuilder) Star() *ExprBuilder
- func (e *ExprBuilder) TypeAssert(typeAssert *ExprBuilder) *ExprBuilder
- func (e *ExprBuilder) TypeAssertExpr(typeAssert ast.Expr) *ExprBuilder
- func (b *ExprBuilder) UnaryAndExpr() *ExprBuilder
- func (b *ExprBuilder) UnaryArrowExpr() *ExprBuilder
- type FieldBuilder
- type FileBuilder
- func (b *FileBuilder) AppendDecl(decl ast.Decl) *FileBuilder
- func (b *FileBuilder) AppendDeclList(decl []ast.Decl) *FileBuilder
- func (b *FileBuilder) AppendFunc(decl *FuncBuilder) *FileBuilder
- func (b *FileBuilder) AppendStruct(decl *StructBuilder) *FileBuilder
- func (b *FileBuilder) Import(path string) *FileBuilder
- func (b *FileBuilder) ImportName(name string, path string) *FileBuilder
- func (b *FileBuilder) Info(projectName, projectUrl string) *FileBuilder
- func (b *FileBuilder) Package(name string) *FileBuilder
- func (b *FileBuilder) Write(fileSet *token.FileSet, path string) error
- type FuncBuilder
- func (fn *FuncBuilder) AppendBody(stmt *StmtBuilder) *FuncBuilder
- func (b *FuncBuilder) D() *ast.FuncDecl
- func (b *FuncBuilder) L() *ast.FuncLit
- func (b *FuncBuilder) Params(builder func(*FieldBuilder)) *FuncBuilder
- func (b *FuncBuilder) ParamsList(fields []*ast.Field) *FuncBuilder
- func (b *FuncBuilder) Recv(builder func(*FieldBuilder)) *FuncBuilder
- func (b *FuncBuilder) RecvList(fields []*ast.Field) *FuncBuilder
- func (b *FuncBuilder) Result(builder func(*FieldBuilder)) *FuncBuilder
- func (b *FuncBuilder) ResultsList(fields []*ast.Field) *FuncBuilder
- func (b *FuncBuilder) SetBody(body func(*StmtBuilder)) *FuncBuilder
- func (fn *FuncBuilder) SetBodyStmt(body []ast.Stmt) *FuncBuilder
- type References
- type StmtBuilder
- func (b *StmtBuilder) Append(stmt ...ast.Stmt) *StmtBuilder
- func (b *StmtBuilder) Assign(value *ExprBuilder, names ...string) *StmtBuilder
- func (b *StmtBuilder) AssignExpr(value *ExprBuilder, identifier []ast.Expr) *StmtBuilder
- func (b *StmtBuilder) AssignToken(value ast.Expr, tok token.Token, identifier []ast.Expr) *StmtBuilder
- func (b *StmtBuilder) Define(value *ExprBuilder, names ...string) *StmtBuilder
- func (b *StmtBuilder) DefineExpr(value *ExprBuilder, identifier []ast.Expr) *StmtBuilder
- func (b *StmtBuilder) First() ast.Stmt
- func (b *StmtBuilder) Go(Call *ast.CallExpr) *StmtBuilder
- func (b *StmtBuilder) IfStmt(cond *ExprBuilder, body func(*StmtBuilder)) *StmtBuilder
- func (b *StmtBuilder) IfStmtExpr(exp ast.Expr, init ast.Stmt, body *ast.BlockStmt) *StmtBuilder
- func (b *StmtBuilder) IfStmtInit(cond *ExprBuilder, init func(*StmtBuilder), body func(*StmtBuilder)) *StmtBuilder
- func (b *StmtBuilder) Include(stmt *StmtBuilder) *StmtBuilder
- func (b *StmtBuilder) Return(exp *ExprBuilder) *StmtBuilder
- func (b *StmtBuilder) ReturnBlock(exp *ExprBlockBuilder) *StmtBuilder
- func (b *StmtBuilder) Returns(exp ...ast.Expr) *StmtBuilder
- func (b *StmtBuilder) ReturnsNames(names ...string) *StmtBuilder
- func (b *StmtBuilder) Send(Chan *ast.Expr, Value *ast.Expr) *StmtBuilder
- func (b *StmtBuilder) Var(typeExpr ast.Expr, names ...string) *StmtBuilder
- func (b *StmtBuilder) VarExpr(typeExpr ast.Expr, names []*ast.Ident) *StmtBuilder
- type StructBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IdentListExpr ¶
func LastExpr ¶
func LastExpr(data *References, expr ast.Expr) ast.Expr
Busca a ultima expressão e adiciona nas referencias
func NewFilename ¶
Remove a extensão do arquivo e adiciona um suffixo
Types ¶
type ExprBlockBuilder ¶
func (*ExprBlockBuilder) Append ¶
func (b *ExprBlockBuilder) Append(expr *ExprBuilder) *ExprBlockBuilder
Adiciona a expressão na lista
func (*ExprBlockBuilder) AppendBlock ¶
func (b *ExprBlockBuilder) AppendBlock(expr *ExprBlockBuilder) *ExprBlockBuilder
Adiciona um bloco de expressão
func (*ExprBlockBuilder) AppendExpr ¶
func (b *ExprBlockBuilder) AppendExpr(expr ast.Expr) *ExprBlockBuilder
Adiciona a expressão na lista
func (*ExprBlockBuilder) AppendExprs ¶
func (b *ExprBlockBuilder) AppendExprs(expr []ast.Expr) *ExprBlockBuilder
Adiciona um bloco de expressão
type ExprBuilder ¶
type ExprBuilder struct {
// contains filtered or unexported fields
}
func Expr ¶
func Expr(name string) *ExprBuilder
Cria uma expressão. Inicialmente tem o valor de &ast.Ident
func (*ExprBuilder) BinaryExpr ¶
func (b *ExprBuilder) BinaryExpr(exp ast.Expr, op token.Token) *ExprBuilder
Operação (ExprBuilder).expr (op) expr
func (*ExprBuilder) Call ¶
func (b *ExprBuilder) Call(exp *ExprBuilder) *ast.CallExpr
*ExprBuilder -> *ast.CallExpr
func (*ExprBuilder) CallExpr ¶
func (b *ExprBuilder) CallExpr(args ...ast.Expr) *ast.CallExpr
...ast.Expr -> *ast.CallExpr
func (*ExprBuilder) CallExprBlock ¶
func (b *ExprBuilder) CallExprBlock(expr *ExprBlockBuilder) *ast.CallExpr
*ExprBlockBuilder -> *ast.CallExpr
func (*ExprBuilder) CallStr ¶
func (b *ExprBuilder) CallStr(args ...string) *ast.CallExpr
...string -> *ast.CallExpr
func (*ExprBuilder) CompositeLit ¶
func (b *ExprBuilder) CompositeLit(elts *ExprBlockBuilder) *ExprBuilder
CompositeLit: ExprBuilder { ExprBlockBuilder }
func (*ExprBuilder) ExprList ¶
func (b *ExprBuilder) ExprList() []ast.Expr
Converte em []ast.Expr { ExprBuilder }
func (*ExprBuilder) Field ¶
func (b *ExprBuilder) Field(names []*ast.Ident) *ast.Field
Convert em campo
func (*ExprBuilder) KeyValue ¶
func (b *ExprBuilder) KeyValue(value *ExprBuilder) *ExprBuilder
KeyValueExpr => key:value
func (*ExprBuilder) NotEquals ¶
func (b *ExprBuilder) NotEquals(expr *ExprBuilder) *ExprBuilder
Não igual (ExprBuilder) != expr
func (*ExprBuilder) NotEqualsExpr ¶
func (b *ExprBuilder) NotEqualsExpr(expr ast.Expr) *ExprBuilder
Não igual (ExprBuilder) != expr
func (*ExprBuilder) NotNil ¶
func (b *ExprBuilder) NotNil() *ExprBuilder
Não nulo (ExprBuilder) != nil
func (*ExprBuilder) Property ¶
func (b *ExprBuilder) Property(property string) *ExprBuilder
Acesso a propriedade (SelectorExpr)
func (*ExprBuilder) TypeAssert ¶
func (e *ExprBuilder) TypeAssert(typeAssert *ExprBuilder) *ExprBuilder
ExprBuilder.(TypeAssert)
func (*ExprBuilder) TypeAssertExpr ¶
func (e *ExprBuilder) TypeAssertExpr(typeAssert ast.Expr) *ExprBuilder
ExprBuilder.(TypeAssert)
func (*ExprBuilder) UnaryAndExpr ¶
func (b *ExprBuilder) UnaryAndExpr() *ExprBuilder
UnaryExpr(Token.AND): & ExprBuilder
func (*ExprBuilder) UnaryArrowExpr ¶
func (b *ExprBuilder) UnaryArrowExpr() *ExprBuilder
UnaryExpr(Token.AND): <- ExprBuilder
type FieldBuilder ¶
type FieldBuilder struct {
// contains filtered or unexported fields
}
func (*FieldBuilder) Field ¶
func (b *FieldBuilder) Field(field []*ast.Field) *FieldBuilder
Adiciona o campo
func (*FieldBuilder) FieldExpr ¶
func (b *FieldBuilder) FieldExpr(field *ExprBuilder) *FieldBuilder
Adiciona o campo
func (*FieldBuilder) Fields ¶
func (b *FieldBuilder) Fields(field ...*ast.Field) *FieldBuilder
Adiciona o campo
type FileBuilder ¶
type FileBuilder struct {
// contains filtered or unexported fields
}
func (*FileBuilder) AppendDecl ¶
func (b *FileBuilder) AppendDecl(decl ast.Decl) *FileBuilder
Adiciona a declaração no corpo do arquivo
func (*FileBuilder) AppendDeclList ¶
func (b *FileBuilder) AppendDeclList(decl []ast.Decl) *FileBuilder
Adiciona a declaração no corpo do arquivo
func (*FileBuilder) AppendFunc ¶
func (b *FileBuilder) AppendFunc(decl *FuncBuilder) *FileBuilder
Adiciona a func no arquivo
func (*FileBuilder) AppendStruct ¶
func (b *FileBuilder) AppendStruct(decl *StructBuilder) *FileBuilder
Adiciona a struct no arquivo
func (*FileBuilder) Import ¶
func (b *FileBuilder) Import(path string) *FileBuilder
Adiciona a importação
func (*FileBuilder) ImportName ¶
func (b *FileBuilder) ImportName(name string, path string) *FileBuilder
Adiciona a importação
func (*FileBuilder) Info ¶
func (b *FileBuilder) Info(projectName, projectUrl string) *FileBuilder
Informações da geração
func (*FileBuilder) Package ¶
func (b *FileBuilder) Package(name string) *FileBuilder
Declaração do pacote do arquivo
type FuncBuilder ¶
type FuncBuilder struct { Name *ast.Ident Body *ast.BlockStmt Type *ast.FuncType // contains filtered or unexported fields }
func Func ¶
func Func(name string, builder func(b *FuncBuilder)) *FuncBuilder
Cria uma nova função (FuncDecl)
func (*FuncBuilder) AppendBody ¶
func (fn *FuncBuilder) AppendBody(stmt *StmtBuilder) *FuncBuilder
Corpo da função
func (*FuncBuilder) D ¶
func (b *FuncBuilder) D() *ast.FuncDecl
func(<recv>) <name>(<param>) <returns> { <body> }
func (*FuncBuilder) Params ¶
func (b *FuncBuilder) Params(builder func(*FieldBuilder)) *FuncBuilder
Parâmetros da função
func (*FuncBuilder) ParamsList ¶
func (b *FuncBuilder) ParamsList(fields []*ast.Field) *FuncBuilder
Parâmetros da função
func (*FuncBuilder) Recv ¶
func (b *FuncBuilder) Recv(builder func(*FieldBuilder)) *FuncBuilder
Recebimento da função
func (*FuncBuilder) RecvList ¶
func (b *FuncBuilder) RecvList(fields []*ast.Field) *FuncBuilder
Recebimento da função
func (*FuncBuilder) Result ¶
func (b *FuncBuilder) Result(builder func(*FieldBuilder)) *FuncBuilder
Retorno da função
func (*FuncBuilder) ResultsList ¶
func (b *FuncBuilder) ResultsList(fields []*ast.Field) *FuncBuilder
Retorno da função
func (*FuncBuilder) SetBody ¶
func (b *FuncBuilder) SetBody(body func(*StmtBuilder)) *FuncBuilder
Corpo da função
func (*FuncBuilder) SetBodyStmt ¶
func (fn *FuncBuilder) SetBodyStmt(body []ast.Stmt) *FuncBuilder
Corpo da função
type References ¶
func NewRefer ¶
func NewRefer() *References
func (*References) Import ¶
func (r *References) Import(f *ast.File, builder *FileBuilder)
Importa as referências
func (*References) Name ¶
func (r *References) Name(importSpec *ast.ImportSpec) string
Retorna o nome do pacote
type StmtBuilder ¶
func (*StmtBuilder) Append ¶
func (b *StmtBuilder) Append(stmt ...ast.Stmt) *StmtBuilder
/ Adiciona um conjunto de ast.Stmt
func (*StmtBuilder) Assign ¶
func (b *StmtBuilder) Assign(value *ExprBuilder, names ...string) *StmtBuilder
Define a variável e inicializa identifier := value
func (*StmtBuilder) AssignExpr ¶
func (b *StmtBuilder) AssignExpr(value *ExprBuilder, identifier []ast.Expr) *StmtBuilder
Define a variável e inicializa identifier := value
func (*StmtBuilder) AssignToken ¶
func (b *StmtBuilder) AssignToken(value ast.Expr, tok token.Token, identifier []ast.Expr) *StmtBuilder
ast.AssignStmt
func (*StmtBuilder) Define ¶
func (b *StmtBuilder) Define(value *ExprBuilder, names ...string) *StmtBuilder
Define a variável identifier = value
func (*StmtBuilder) DefineExpr ¶
func (b *StmtBuilder) DefineExpr(value *ExprBuilder, identifier []ast.Expr) *StmtBuilder
Define a variável identifier = value
func (*StmtBuilder) Go ¶
func (b *StmtBuilder) Go(Call *ast.CallExpr) *StmtBuilder
GoStmt: go Call (*ast.Expr)
func (*StmtBuilder) IfStmt ¶
func (b *StmtBuilder) IfStmt(cond *ExprBuilder, body func(*StmtBuilder)) *StmtBuilder
IfStmt
func (*StmtBuilder) IfStmtExpr ¶
func (b *StmtBuilder) IfStmtExpr(exp ast.Expr, init ast.Stmt, body *ast.BlockStmt) *StmtBuilder
IfStmt
func (*StmtBuilder) IfStmtInit ¶
func (b *StmtBuilder) IfStmtInit(cond *ExprBuilder, init func(*StmtBuilder), body func(*StmtBuilder)) *StmtBuilder
IfStmt
func (*StmtBuilder) Include ¶
func (b *StmtBuilder) Include(stmt *StmtBuilder) *StmtBuilder
Adiciona outro StmtBlockBuilder
func (*StmtBuilder) Return ¶
func (b *StmtBuilder) Return(exp *ExprBuilder) *StmtBuilder
Retorno da função
func (*StmtBuilder) ReturnBlock ¶
func (b *StmtBuilder) ReturnBlock(exp *ExprBlockBuilder) *StmtBuilder
Retorno da função
func (*StmtBuilder) Returns ¶
func (b *StmtBuilder) Returns(exp ...ast.Expr) *StmtBuilder
Retorno da função
func (*StmtBuilder) ReturnsNames ¶
func (b *StmtBuilder) ReturnsNames(names ...string) *StmtBuilder
Retorno da função
func (*StmtBuilder) Send ¶
func (b *StmtBuilder) Send(Chan *ast.Expr, Value *ast.Expr) *StmtBuilder
SendStmt: Chan(*ast.Expr) <- Value (*ast.Expr)
func (*StmtBuilder) Var ¶
func (b *StmtBuilder) Var(typeExpr ast.Expr, names ...string) *StmtBuilder
Cria uma variável var name1, name2... type
func (*StmtBuilder) VarExpr ¶
func (b *StmtBuilder) VarExpr(typeExpr ast.Expr, names []*ast.Ident) *StmtBuilder
Cria uma variável var name1, name2... type
type StructBuilder ¶
type StructBuilder struct {
// contains filtered or unexported fields
}
func Struct ¶
func Struct(name string, builder func(s *StructBuilder)) *StructBuilder
Estrutura de dados
func (*StructBuilder) Field ¶
func (b *StructBuilder) Field(builder func(*FieldBuilder)) *StructBuilder
Adiciona o campo
func (*StructBuilder) GenDecl ¶
func (b *StructBuilder) GenDecl() *ast.GenDecl
Converte em ast.GenDecl