3 ms·
Why not use the standard-library adjacent semaphore package? One problem with using a channel as a semaphore is you need to track if you've closed the channel
by sa46 1y ago
Why not use the standard-library adjacent semaphore package?
One problem with using a channel as a semaphore is you need to track if you've closed the channel when "releasing".
https://pkg.go.dev/golang.org/x/sync/semaphore#Weighted.Acquire https://pkg.go.dev/golang.org/x/sync/semaphore#Weighted.Acqu...