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) *SignatureParameters & Attributes
| Name | Type | Description |
|---|---|---|
| recv | *Var | Input to the operation as described above. |
| recvTypeParams | []*TypeParam | Input to the operation as described above. |
| typeParams | []*TypeParam | Input to the operation as described above. |
| params | *Tuple | Input to the operation as described above. |
| results | *Tuple | Input to the operation as described above. |
| variadic | bool | Input 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)}