SkillAgentSearch skills...

Chann

a unified channel package for buffered, unbuffered, and unbounded channels

Install / Use

/learn @golang-design/Chann
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

chann example workflow

a unified channel package in Go

import "golang.design/x/chann"

This package requires Go 1.18.

Basic Usage

Different types of channels:

ch := chann.New[int]()                  // unbounded, capacity unlimited
ch := chann.New[func()](chann.Cap(0))   // unbufferd, capacity 0
ch := chann.New[string](chann.Cap(100)) // buffered,  capacity 100

Send and receive operations:

ch.In() <- 42
println(<-ch.Out()) // 42

Close operation:

ch.Close()

Channel properties:

ch.Len() // the length of the channel
ch.Cap() // the capacity of the channel

See https://golang.design/research/ultimate-channel for more details of the motivation of this abstraction.

License

MIT | © 2021 The golang.design Initiative Authors, written by Changkun Ou.

View on GitHub
GitHub Stars43
CategoryDevelopment
Updated4mo ago
Forks6

Languages

Go

Security Score

92/100

Audited on Nov 29, 2025

No findings