From 7e594abd1a92011086ec6b4fd4680ded890da7a7 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Tue, 24 Mar 2020 07:09:08 -0600 Subject: [PATCH] staticcheck --- main.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index f3a91c6..82f2e43 100644 --- a/main.go +++ b/main.go @@ -48,10 +48,10 @@ func init() { } p, err := os.Open(passPath) - defer p.Close() if err != nil { log.Fatal(err) } + defer p.Close() ht := csv.NewReader(p) ht.Comma = ':' @@ -76,10 +76,7 @@ func validate(user string, pass string) bool { } err := bcrypt.CompareHashAndPassword([]byte(htpass), []byte(pass)) - if err == nil { - return true - } - return false + return err == nil } func main() { @@ -104,7 +101,7 @@ func main() { mux.Handle("/", http.FileServer(http.Dir(staticDir))) mux.HandleFunc(prefix, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { user, pass, ok := r.BasicAuth() - if !(ok == true && validate(user, pass)) { + if !(ok && validate(user, pass)) { w.Header().Set("WWW-Authenticate", `Basic realm="davfs"`) http.Error(w, "Unauthorized", http.StatusUnauthorized) return