Skip to content

Commit c456d6e

Browse files
committed
staticcheck: fix S1012,S1024: use time.Until and time.Since
Signed-off-by: Sumner Evans <[email protected]>
1 parent 1fbdaa3 commit c456d6e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

disappearing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (dmm *DisappearingMessagesManager) StartDisappearingLoop(ctx context.Contex
7575
log.Err(err).Msg("Failed to get next disappearing message")
7676
continue
7777
} else if nextMsg != nil {
78-
duration = nextMsg.ExpireAt.Sub(time.Now())
78+
duration = time.Until(nextMsg.ExpireAt)
7979
}
8080

8181
select {

metrics.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (mh *MetricsHandler) TrackMatrixEvent(eventType event.Type) func() {
146146
}
147147
start := time.Now()
148148
return func() {
149-
duration := time.Now().Sub(start)
149+
duration := time.Since(start)
150150
mh.matrixEventHandling.
151151
With(prometheus.Labels{"event_type": eventType.Type}).
152152
Observe(duration.Seconds())
@@ -160,11 +160,11 @@ func (mh *MetricsHandler) TrackSignalMessage(timestamp time.Time, messageType st
160160

161161
start := time.Now()
162162
return func() {
163-
duration := time.Now().Sub(start)
163+
duration := time.Since(start)
164164
mh.signalMessageHandling.
165165
With(prometheus.Labels{"message_type": messageType}).
166166
Observe(duration.Seconds())
167-
mh.signalMessageAge.Observe(time.Now().Sub(timestamp).Seconds())
167+
mh.signalMessageAge.Observe(time.Since(timestamp).Seconds())
168168
}
169169
}
170170

@@ -271,7 +271,7 @@ func (mh *MetricsHandler) updateStats() {
271271
mh.unencryptedGroupCount.Set(float64(unencryptedGroupCount))
272272
mh.unencryptedPrivateCount.Set(float64(encryptedPrivateCount))
273273
}
274-
mh.countCollection.Observe(time.Now().Sub(start).Seconds())
274+
mh.countCollection.Observe(time.Since(start).Seconds())
275275
}
276276

277277
func (mh *MetricsHandler) startUpdatingStats() {

0 commit comments

Comments
 (0)