From 6baa93e13f956fcb0d58d565c22fdf64576baade Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Thu, 28 Jul 2022 18:49:44 +0200 Subject: [PATCH] lib/api: String comparisons --- cmd/strelaypoolsrv/main.go | 2 +- lib/api/api.go | 2 +- lib/api/api_statics.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/strelaypoolsrv/main.go b/cmd/strelaypoolsrv/main.go index be54fd3b9..063097017 100644 --- a/cmd/strelaypoolsrv/main.go +++ b/cmd/strelaypoolsrv/main.go @@ -572,7 +572,7 @@ func loadRelays(file string) []*relay { var relays []*relay for _, line := range strings.Split(string(content), "\n") { - if len(line) == 0 { + if line == "" { continue } diff --git a/lib/api/api.go b/lib/api/api.go index 3ee96554f..07b3af408 100644 --- a/lib/api/api.go +++ b/lib/api/api.go @@ -1017,7 +1017,7 @@ func (s *service) postSystemReset(w http.ResponseWriter, r *http.Request) { } } - if len(folder) == 0 { + if folder == "" { // Reset all folders. for folder := range s.cfg.Folders() { if err := s.model.ResetFolder(folder); err != nil { diff --git a/lib/api/api_statics.go b/lib/api/api_statics.go index 4bd9c1c21..b63908dde 100644 --- a/lib/api/api_statics.go +++ b/lib/api/api_statics.go @@ -81,7 +81,7 @@ func (s *staticsServer) serveAsset(w http.ResponseWriter, r *http.Request) { file = file[1:] } - if len(file) == 0 { + if file == "" { file = "index.html" } @@ -136,7 +136,7 @@ func (s *staticsServer) serveFromAssetDir(file, theme string, w http.ResponseWri return false } mtype := assets.MimeTypeForFile(file) - if len(mtype) != 0 { + if mtype == "" { w.Header().Set("Content-Type", mtype) } http.ServeFile(w, r, p)