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) Type

Parameters & Attributes

NameTypeDescription
in[]TypeOrdered input parameter types.
out[]TypeOrdered result types.
variadicboolWhether 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))}
Go Reference