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) *Chan

Parameters & Attributes

NameTypeDescription
dirChanDirChannel direction.
elemTypeElement 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])) }
Go Reference