Standard library / reflect
reflect.ChanOf()
Construct a channel type with a direction and element type. It does not create a channel. Expected stdout: '<-chan int\n'.
Formal Syntax & Structure
go syntaxgo
func ChanOf(dir ChanDir, t Type) TypeParameters & Attributes
| Name | Type | Description |
|---|---|---|
| dir | ChanDir | Channel direction. |
| t | Type | Element type of the new composite type. |
Return Value
Type
Construct a channel type with a direction and element type.
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { fmt.Println(reflect.ChanOf(reflect.RecvDir, reflect.TypeOf(0))) }