First time using semaphores in golang! They are really useful for limiting the number of concurrent connections being handled by a server. They are also really easy to understand - acquire 1 from the semaphore (locking if 1 is not available), and then release it when the connection is finished. Other people use channels, but channels are over-complicated for something as simple as this, imo.
For anyone wondering, I'm using this package: golang.org/x/sync/semaphore
1 year ago