Standard library / go/types
go/types.NewFunc()
Creates a function or method object with the supplied signature. Expected stdout: 'Work func()\n'.
Formal Syntax & Structure
go syntaxgo
func NewFunc(pos token.Pos, pkg *Package, name string, sig *Signature) *FuncParameters & Attributes
| Name | Type | Description |
|---|---|---|
| pos | token.Pos | Source position in the associated file set. |
| pkg | *Package | Package containing the symbol; nil for package-independent objects. |
| name | string | Name of the symbol or package. |
| sig | *Signature | Input to the operation as described above. |
Return Value
*Func
Creates a function or method object with the supplied signature.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/types")
func main() { f := types.NewFunc(0, nil, "Work", types.NewSignatureType(nil, nil, nil, nil, nil, false)) fmt.Println(f.Name(), f.Type())}