Standard library / reflect
reflect.MakeChan()
Creates a non-nil bidirectional channel of the given channel type and buffer size. Expected stdout: '8\n'.
Formal Syntax & Structure
go syntaxgo
func MakeChan(typ Type, buffer int) ValueParameters & Attributes
| Name | Type | Description |
|---|---|---|
| typ | Type | Runtime type descriptor for the new value. |
| buffer | int | Nonnegative channel buffer capacity. |
Return Value
Value
Creates a non-nil bidirectional channel of the given channel type and buffer size.
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { v := reflect.MakeChan(reflect.TypeFor[chan int](), 1) v.Send(reflect.ValueOf(8)) x, _ := v.Recv() fmt.Println(x.Int())}