Skip to content

Commit

Permalink
Merge pull request #429 from xushiwei/q
Browse files Browse the repository at this point in the history
pkg.NewFuncDecl doc
  • Loading branch information
xushiwei committed May 14, 2024
2 parents 0d40138 + 0126c40 commit 7468f9e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions func.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand All @@ -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 == "" {
Expand Down

0 comments on commit 7468f9e

Please sign in to comment.