Skip to content

Instantly share code, notes, and snippets.

Evar (
concurrent = 5
semaphoreChan = make(chan struct{}, concurrent)
)
func doWork(item int) {
semaphoreChan <- struct{}{} // block while full
go func() {
defer func() {
<-semaphoreChan // read to release a slot