Skip to content

Commit d580fb1

Browse files
committed
Clean up some code from linter suggestion
1 parent ad52c97 commit d580fb1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

logrequest.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type statusWriter struct {
2525

2626
// ToLogger will print the Started and Completed request info to the passed logger
2727
func (lr LogRequest) ToLogger(logger *log.Logger) {
28-
if lr.Timestamp == true {
28+
if lr.Timestamp {
2929
logger.Printf(`Started %s "%s" %s %s at %s`, lr.Request.Method, lr.Request.URL.RequestURI(), lr.Request.RemoteAddr, lr.Request.Proto, time.Now().Format("2006-01-02 15:04:05"))
3030
} else {
3131
logger.Printf(`Started %s "%s" %s %s`, lr.Request.Method, lr.Request.URL.RequestURI(), lr.Request.RemoteAddr, lr.Request.Proto)
@@ -52,7 +52,7 @@ func (lr LogRequest) ToString() map[string]string {
5252
sw, completedDuration := lr.parseRequest()
5353
ts := make(map[string]string)
5454

55-
if lr.Timestamp == true {
55+
if lr.Timestamp {
5656
ts["started"] = fmt.Sprintf(`Started %s "%s" %s %s at %s`, lr.Request.Method, lr.Request.URL.RequestURI(), lr.Request.RemoteAddr, lr.Request.Proto, time.Now().Format("2006-01-02 15:04:05"))
5757
} else {
5858
ts["started"] = fmt.Sprintf(`Started %s "%s" %s %s`, lr.Request.Method, lr.Request.URL.RequestURI(), lr.Request.RemoteAddr, lr.Request.Proto)
@@ -74,7 +74,7 @@ func (lr LogRequest) parseRequest() (statusWriter, time.Duration) {
7474
startTime := time.Now()
7575
sw := statusWriter{ResponseWriter: lr.Writer}
7676
lr.Handler.ServeHTTP(&sw, lr.Request)
77-
return sw, time.Now().Sub(startTime)
77+
return sw, time.Since(startTime)
7878
}
7979

8080
func (w *statusWriter) WriteHeader(statusCode int) {

0 commit comments

Comments
 (0)