Standard library / go/types

go/types.NewSignatureType()

Constructs a signature with optional receiver and type parameters. A variadic signature must have an appropriate final parameter. Expected stdout: 'func(x int)\n'.

Formal Syntax & Structure

go syntaxgo
func NewSignatureType(recv *Var, recvTypeParams, typeParams []*TypeParam, params, results *Tuple, variadic bool) *Signature

Parameters & Attributes

NameTypeDescription
recv*VarInput to the operation as described above.
recvTypeParams[]*TypeParamInput to the operation as described above.
typeParams[]*TypeParamInput to the operation as described above.
params*TupleInput to the operation as described above.
results*TupleInput to the operation as described above.
variadicboolInput to the operation as described above.

Return Value

*Signature

Constructs a signature with optional receiver and type parameters.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/types")
func main() {  p := types.NewParam(0, nil, "x", types.Typ[types.Int])  s := types.NewSignatureType(nil, nil, nil, types.NewTuple(p), nil, false)  fmt.Println(s)}
Go Reference