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) *Func

Parameters & Attributes

NameTypeDescription
postoken.PosSource position in the associated file set.
pkg*PackagePackage containing the symbol; nil for package-independent objects.
namestringName of the symbol or package.
sig*SignatureInput 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())}
Go Reference