Embedding Types to Reuse Code with Less Noise
2020-04-30
My previous post was about one of the concurrency patterns that can be achieved with go. I immediately got some feedback on it, and this is where I will address one of them.
You have seen the code reimplementing sync.WaitGroup to have a semaphore in it.
type WaitGroup interface { Add(delta int) Done() Wait() } type SemaphoredWaitGroup struct { sem chan bool wg sync.WaitGroup } func (s *SemaphoredWaitGroup) Add(delta int) { s.…