Standard library / reflect
reflect.FuncOf()
Construct a function type from ordered input and result types. A variadic function must end with a slice input. Expected stdout: 'func(int) int\n'.
Formal Syntax & Structure
go syntaxgo
func FuncOf(in, out []Type, variadic bool) TypeParameters & Attributes
| Name | Type | Description |
|---|---|---|
| in | []Type | Ordered input parameter types. |
| out | []Type | Ordered result types. |
| variadic | bool | Whether the last input is a variadic slice parameter. |
Return Value
Type
Construct a function type from ordered input and result types.
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { t := reflect.TypeOf(0) fmt.Println(reflect.FuncOf([]reflect.Type{t}, []reflect.Type{t}, false))}