From 67299a280878fe46c950bec1544bd4878537c847 Mon Sep 17 00:00:00 2001 From: Seednode Date: Sun, 11 Sep 2022 20:05:55 -0500 Subject: [PATCH] Simplified timestamp functions --- cmd/version.go | 2 +- cmd/web.go | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/version.go b/cmd/version.go index 2109abb..424ccc7 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/cobra" ) -var Version = "0.5.0" +var Version = "0.5.1" func init() { rootCmd.AddCommand(versionCmd) diff --git a/cmd/web.go b/cmd/web.go index e90e4ca..04b7a8b 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -95,11 +95,10 @@ func serveStaticFile(w http.ResponseWriter, r http.Request, paths []string) erro } var startTime time.Time - var stopTime time.Time if Verbose { - fmt.Printf("%v Serving file: %v", time.Now().Format(LOGDATE), filePath) startTime = time.Now() + fmt.Printf("%v Serving file: %v", startTime.Format(LOGDATE), filePath) } buf, err := os.ReadFile(filePath) @@ -110,9 +109,7 @@ func serveStaticFile(w http.ResponseWriter, r http.Request, paths []string) erro w.Write(buf) if Verbose { - stopTime = time.Now() - timeElapsed := stopTime.Sub(startTime).Round(time.Microsecond) - fmt.Printf("%v %v\n", " - Finished in", timeElapsed) + fmt.Printf("- Finished in %v\n", time.Now().Sub(startTime).Round(time.Microsecond)) } return nil