Standard library / reflect
reflect.TypeFor()
Obtain a descriptor for a type argument without creating a value; available since Go 1.22. Expected stdout: 'interface\n'.
Formal Syntax & Structure
go syntaxgo
func TypeFor[T any]() TypeReturn Value
Type
Type descriptor for T, including interface types.
Working Example
Example Snippetgo
package main
import ( "fmt" "io" "reflect")
func main() { fmt.Println(reflect.TypeFor[io.Reader]().Kind()) }