From d1f1b2e90bd22d00e792b1a4cfe468044028ea22 Mon Sep 17 00:00:00 2001 From: Seednode Date: Wed, 21 Sep 2022 21:24:05 -0500 Subject: [PATCH] Use raw strings instead of quoted strings for regexp.MustCompile, replaced time.Now().Sub with time.Since, fixed clobbered filePath value, per staticcheck --- cmd/files.go | 4 ++-- cmd/version.go | 2 +- cmd/web.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/files.go b/cmd/files.go index 22b1d12..b5a3fe4 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -18,7 +18,7 @@ import ( ) func getFirstFile(path string) (string, error) { - re := regexp.MustCompile("(.+)([0-9]{3})(\\..+)") + re := regexp.MustCompile(`(.+)([0-9]{3})(\..+)`) split := re.FindAllStringSubmatch(path, -1) @@ -45,7 +45,7 @@ func getFirstFile(path string) (string, error) { } func getNextFile(path string) (string, error) { - re := regexp.MustCompile("(.+)([0-9]{3})(\\..+)") + re := regexp.MustCompile(`(.+)([0-9]{3})(\..+)`) split := re.FindAllStringSubmatch(path, -1) diff --git a/cmd/version.go b/cmd/version.go index 8bb391d..bec870a 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/cobra" ) -var Version = "0.8.2" +var Version = "0.8.3" func init() { rootCmd.AddCommand(versionCmd) diff --git a/cmd/web.go b/cmd/web.go index 471a0f8..c26e7b2 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -73,7 +73,7 @@ func serveStaticFile(w http.ResponseWriter, r http.Request, paths []string) erro matchesPrefix = true } } - if matchesPrefix == false { + if !matchesPrefix { if Verbose { fmt.Printf("%v Failed to serve file outside specified path(s): %v", time.Now().Format(LOGDATE), filePath) } @@ -110,7 +110,7 @@ func serveStaticFile(w http.ResponseWriter, r http.Request, paths []string) erro w.Write(buf) if Verbose { - fmt.Printf(" (Finished in %v)\n", time.Now().Sub(startTime).Round(time.Microsecond)) + fmt.Printf(" (Finished in %v)\n", time.Since(startTime).Round(time.Microsecond)) } return nil @@ -142,7 +142,7 @@ func serveHtmlHandler(paths []string) http.HandlerFunc { } if filePath == "" { - filePath, err := pickFile(paths) + filePath, err = pickFile(paths) if err != nil { log.Fatal(err) }