Use raw strings instead of quoted strings for regexp.MustCompile, replaced time.Now().Sub with time.Since, fixed clobbered filePath value, per staticcheck
This commit is contained in:
parent
79331096a9
commit
d1f1b2e90b
|
@ -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)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var Version = "0.8.2"
|
||||
var Version = "0.8.3"
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue