From 0126c408ed48121e6abc3c2f1ac992f3f839650f Mon Sep 17 00:00:00 2001 From: xushiwei Date: Tue, 14 May 2024 18:09:11 +0800 Subject: [PATCH] pkg.NewFuncDecl doc --- func.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/func.go b/func.go index dfb80a30..1473b103 100644 --- a/func.go +++ b/func.go @@ -132,6 +132,7 @@ func (p *Func) End(cb *CodeBuilder, src ast.Node) { } } +// NewFuncDecl creates a new function without function body (declaration only). func (p *Package) NewFuncDecl(pos token.Pos, name string, sig *types.Signature) *Func { f, err := p.NewFuncWith(pos, name, sig, nil) if err != nil { @@ -142,7 +143,7 @@ func (p *Package) NewFuncDecl(pos token.Pos, name string, sig *types.Signature) return f } -// NewFunc func +// NewFunc creates a new function (should have a function body). func (p *Package) NewFunc(recv *Param, name string, params, results *Tuple, variadic bool) *Func { sig := types.NewSignatureType(recv, nil, nil, params, results, variadic) f, err := p.NewFuncWith(token.NoPos, name, sig, nil) @@ -159,7 +160,7 @@ func getRecv(recvTypePos func() token.Pos) token.Pos { return token.NoPos } -// NewFuncWith func +// NewFuncWith creates a new function (should have a function body). func (p *Package) NewFuncWith( pos token.Pos, name string, sig *types.Signature, recvTypePos func() token.Pos) (*Func, error) { if name == "" {