staticcheck (#313)
* CI: use staticcheck for linting This commit switches the linter for Go code from golint to staticcheck. Golint has been deprecated since last year and staticcheck is a recommended replacement. Signed-off-by: Lucas Servén Marín <lserven@gmail.com> * revendor Signed-off-by: Lucas Servén Marín <lserven@gmail.com> * cmd,pkg: fix lint warnings Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit is contained in:
committed by
GitHub
parent
93f46e03ea
commit
50fbc2eec2
36
vendor/honnef.co/go/tools/internal/sync/sync.go
vendored
Normal file
36
vendor/honnef.co/go/tools/internal/sync/sync.go
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
package sync
|
||||
|
||||
type Semaphore struct {
|
||||
ch chan struct{}
|
||||
}
|
||||
|
||||
func NewSemaphore(size int) Semaphore {
|
||||
return Semaphore{
|
||||
ch: make(chan struct{}, size),
|
||||
}
|
||||
}
|
||||
|
||||
func (sem Semaphore) Acquire() {
|
||||
sem.ch <- struct{}{}
|
||||
}
|
||||
|
||||
func (sem Semaphore) AcquireMaybe() bool {
|
||||
select {
|
||||
case sem.ch <- struct{}{}:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (sem Semaphore) Release() {
|
||||
<-sem.ch
|
||||
}
|
||||
|
||||
func (sem Semaphore) Len() int {
|
||||
return len(sem.ch)
|
||||
}
|
||||
|
||||
func (sem Semaphore) Cap() int {
|
||||
return cap(sem.ch)
|
||||
}
|
Reference in New Issue
Block a user