package semaphore type Semaphore chan struct{} func MakeSemaphore(n int) Semaphore { return make(Semaphore, n) } func (s Semaphore) Acquire() { s <- struct{}{} } func (s Semaphore) Release() { <-s }