Skip to content

Commit f89114a

Browse files
committed
all: address gosimple linter errors
1 parent c96d04a commit f89114a

File tree

15 files changed

+26
-49
lines changed

15 files changed

+26
-49
lines changed

.golangci-lint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ linters:
66
- errcheck
77
- ineffassign
88
- govet
9+
- gosimple
910

1011
issues:
1112
exclude-rules:

pkg/code/async/account/service.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ func (p *service) Start(ctx context.Context, interval time.Duration) error {
4242
}
4343
}()
4444

45-
select {
46-
case <-ctx.Done():
47-
return ctx.Err()
48-
}
45+
<-ctx.Done()
46+
return ctx.Err()
4947
}

pkg/code/async/commitment/service.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ func (p *service) Start(ctx context.Context, interval time.Duration) error {
4949
}
5050
}()
5151

52-
select {
53-
case <-ctx.Done():
54-
return ctx.Err()
55-
}
52+
<-ctx.Done()
53+
return ctx.Err()
5654
}

pkg/code/async/geyser/service.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ func (p *service) Start(ctx context.Context, _ time.Duration) error {
111111
}()
112112

113113
// Wait for the service to stop
114-
select {
115-
case <-ctx.Done():
116-
}
114+
<-ctx.Done()
117115

118116
// Gracefully shutdown
119117
close(p.programUpdatesChan)

pkg/code/async/sequencer/service.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ func (p *service) Start(ctx context.Context, interval time.Duration) error {
7474
}
7575
}()
7676

77-
select {
78-
case <-ctx.Done():
79-
return ctx.Err()
80-
}
77+
<-ctx.Done()
78+
return ctx.Err()
8179
}

pkg/code/async/treasury/service.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ func (p *service) Start(ctx context.Context, interval time.Duration) error {
5151
}
5252
}()
5353

54-
select {
55-
case <-ctx.Done():
56-
return ctx.Err()
57-
}
54+
<-ctx.Done()
55+
return ctx.Err()
5856
}

pkg/code/async/user/service.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ func (p *service) Start(ctx context.Context, interval time.Duration) error {
4747
}
4848
}()
4949

50-
select {
51-
case <-ctx.Done():
52-
return ctx.Err()
53-
}
50+
<-ctx.Done()
51+
return ctx.Err()
5452
}

pkg/code/async/webhook/service.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ func (p *service) Start(ctx context.Context, interval time.Duration) error {
5050
}
5151
}()
5252

53-
select {
54-
case <-ctx.Done():
55-
return ctx.Err()
56-
}
53+
<-ctx.Done()
54+
return ctx.Err()
5755
}

pkg/code/data/transaction/memory/store.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"sort"
66
"sync"
77

8-
"github.com/code-payments/code-server/pkg/database/query"
98
"github.com/code-payments/code-server/pkg/code/data/transaction"
9+
"github.com/code-payments/code-server/pkg/database/query"
1010
)
1111

1212
type store struct {
@@ -45,8 +45,7 @@ func (s *store) Put(ctx context.Context, data *transaction.Record) error {
4545
defer s.transactionStoreMu.Unlock()
4646
s.lastIndex++
4747

48-
var clone transaction.Record
49-
clone = *data
48+
clone := *data
5049

5150
for index, item := range s.transactionStore {
5251
if item.Signature == data.Signature {

pkg/code/server/grpc/currency/currency.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (s *currencyServer) GetAllRates(ctx context.Context, req *currencypb.GetAll
4141
var record *currency.MultiRateRecord
4242
if req.Timestamp != nil && req.Timestamp.AsTime().Before(time.Now().Add(-15*time.Minute)) {
4343
record, err = s.LoadExchangeRatesForTime(ctx, req.Timestamp.AsTime())
44-
} else if req.Timestamp == nil || req.Timestamp.AsTime().Sub(time.Now()) < time.Hour {
44+
} else if req.Timestamp == nil || time.Until(req.Timestamp.AsTime()) < time.Hour {
4545
record, err = s.LoadExchangeRatesLatest(ctx)
4646
} else {
4747
return nil, status.Error(codes.InvalidArgument, "timestamp too far in the future")

0 commit comments

Comments
 (0)