Skip to content

Commit

Permalink
staticcheck: fix S1012,S1024: use time.Until and time.Since
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <me@sumnerevans.com>
  • Loading branch information
sumnerevans committed Jan 8, 2024
1 parent 1fbdaa3 commit c456d6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion disappearing.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (dmm *DisappearingMessagesManager) StartDisappearingLoop(ctx context.Contex
log.Err(err).Msg("Failed to get next disappearing message")
continue
} else if nextMsg != nil {
duration = nextMsg.ExpireAt.Sub(time.Now())
duration = time.Until(nextMsg.ExpireAt)
}

select {
Expand Down
8 changes: 4 additions & 4 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (mh *MetricsHandler) TrackMatrixEvent(eventType event.Type) func() {
}
start := time.Now()
return func() {
duration := time.Now().Sub(start)
duration := time.Since(start)
mh.matrixEventHandling.
With(prometheus.Labels{"event_type": eventType.Type}).
Observe(duration.Seconds())
Expand All @@ -160,11 +160,11 @@ func (mh *MetricsHandler) TrackSignalMessage(timestamp time.Time, messageType st

start := time.Now()
return func() {
duration := time.Now().Sub(start)
duration := time.Since(start)
mh.signalMessageHandling.
With(prometheus.Labels{"message_type": messageType}).
Observe(duration.Seconds())
mh.signalMessageAge.Observe(time.Now().Sub(timestamp).Seconds())
mh.signalMessageAge.Observe(time.Since(timestamp).Seconds())
}
}

Expand Down Expand Up @@ -271,7 +271,7 @@ func (mh *MetricsHandler) updateStats() {
mh.unencryptedGroupCount.Set(float64(unencryptedGroupCount))
mh.unencryptedPrivateCount.Set(float64(encryptedPrivateCount))
}
mh.countCollection.Observe(time.Now().Sub(start).Seconds())
mh.countCollection.Observe(time.Since(start).Seconds())
}

func (mh *MetricsHandler) startUpdatingStats() {
Expand Down

0 comments on commit c456d6e

Please sign in to comment.