Skip to content

Commit

Permalink
Fixed golangcli-lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rdy committed Nov 18, 2023
1 parent 7ab5c2d commit eb1ce71
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions types/future.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ type Future[T any] struct {
// NewFuture creates a new future.
func NewFuture[T any]() Future[T] {
sem := semaphore.NewWeighted(1)
sem.Acquire(context.Background(), 1)
err := sem.Acquire(context.Background(), 1)
if err != nil {
// this should never happen, as the semaphore is created one line before - please, report an issue if it does
panic(err)
}

return Future[T]{
sem: sem,
Expand All @@ -51,7 +55,11 @@ func NewFuture[T any]() Future[T] {
// As an alternative consider using GetWithTimeout() method.
func (f *Future[T]) Get() (*T, error) {
if !f.done {
f.sem.Acquire(context.Background(), 1)
err := f.sem.Acquire(context.Background(), 1)
if err != nil {
// this should never happen - please, report an issue if it does
return nil, err
}
}
return f.value, f.err
}
Expand Down

0 comments on commit eb1ce71

Please sign in to comment.