should use time.Since instead of time.Now().Sub
56 if level == "all" {
57 // Send success notifications.
58 if job.Status.Succeeded > 0 && (job.Status.CompletionTime.Add(20*time.Minute).Unix() > time.Now().Unix()) {
59 timeSinceCompletion := time.Now().Sub(job.Status.CompletionTime.Time).Minutes()60 err = slack.SendSlackMessage(message.JobSuccess(clusterName, job.Name, timeSinceCompletion))
61 if err != nil {
62 log.Fatalf("sending a message to slack failed %v", zap.Error(err))
Description
The time.Since(t)
helper has the same effect as using time.Now().Sub(t)
.
time.Since(t)
returns the time elapsed since t
. It is shorthand for
time.Now().Sub(t)
.
Bad practice
time.Now().Sub(x)
Recommended
time.Since(x)