Skip to content

Commit

Permalink
Make use of time.Since
Browse files Browse the repository at this point in the history
Use time.Since instead of manually subtracting timestamps.
  • Loading branch information
muesli committed Jul 19, 2019
1 parent 139c8bc commit 1b28e67
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/trustydns-server/main.go
Expand Up @@ -308,7 +308,7 @@ func nextInterval(now time.Time, interval time.Duration) time.Duration {
// upTime calculates how long this server has been running and returns log-friendly and
// granularity-appropriate representation of that duration.
func uptime() string {
return time.Now().Sub(startTime).Truncate(time.Second).String()
return time.Since(startTime).Truncate(time.Second).String()
}

// statusReport prints stats about the server and all known reporters
Expand Down
2 changes: 1 addition & 1 deletion cmd/trustydns-server/server.go
Expand Up @@ -278,7 +278,7 @@ func (t *server) serveDoH(writer http.ResponseWriter, httpReq *http.Request) {

// Return message to caller

duration := time.Now().Sub(startTime)
duration := time.Since(startTime)
writer.Header().Set(consts.ContentTypeHeader, consts.Rfc8484AcceptValue)
writer.Header().Set(consts.TrustyDurationHeader, duration.String())

Expand Down

0 comments on commit 1b28e67

Please sign in to comment.