Standard library / go/types
go/types.NewChan()
Constructs a chan type descriptor. This does not allocate a runtime value. Expected stdout: 'chan<- int\n'.
Formal Syntax & Structure
go syntaxgo
func NewChan(dir ChanDir, elem Type) *ChanParameters & Attributes
| Name | Type | Description |
|---|---|---|
| dir | ChanDir | Channel direction. |
| elem | Type | Element type. |
Return Value
*Chan
Constructs a chan type descriptor.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/types")
func main() { fmt.Println(types.NewChan(types.SendOnly, types.Typ[types.Int])) }