From 2327f93098b4278c93055a96224ae82cef60b083 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Sun, 15 Feb 2026 13:48:34 -0800 Subject: Backend: Fix linting issues, improve error handling, and replace magic numbers --- api/api.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'api/api.go') diff --git a/api/api.go b/api/api.go index 9ea35c8..6833ce4 100644 --- a/api/api.go +++ b/api/api.go @@ -45,12 +45,12 @@ func (s *Server) routes() { func jsonError(w http.ResponseWriter, msg string, code int) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(code) - json.NewEncoder(w).Encode(map[string]string{"error": msg}) + _ = json.NewEncoder(w).Encode(map[string]string{"error": msg}) } func jsonResponse(w http.ResponseWriter, data interface{}) { w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) + _ = json.NewEncoder(w).Encode(data) } func (s *Server) HandleStream(w http.ResponseWriter, r *http.Request) { @@ -65,7 +65,7 @@ func (s *Server) HandleStream(w http.ResponseWriter, r *http.Request) { // Backward compatibility with feed_url if feed_id is not provided if feedID == 0 && r.FormValue("feed_url") != "" { var f feed.Feed - f.ByUrl(r.FormValue("feed_url")) + _ = f.ByUrl(r.FormValue("feed_url")) feedID = f.Id } @@ -157,7 +157,7 @@ func (s *Server) HandleFeed(w http.ResponseWriter, r *http.Request) { jsonError(w, "failed to create feed", http.StatusInternalServerError) return } - f.ByUrl(f.Url) + _ = f.ByUrl(f.Url) ch := make(chan string) go func() { crawler.CrawlFeed(&f, ch) @@ -165,7 +165,7 @@ func (s *Server) HandleFeed(w http.ResponseWriter, r *http.Request) { }() w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusCreated) - json.NewEncoder(w).Encode(f) + _ = json.NewEncoder(w).Encode(f) case http.MethodPut: var f feed.Feed @@ -237,7 +237,7 @@ func (s *Server) HandleExport(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", contentType) w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=neko_export.%s", extension)) - w.Write([]byte(exporter.ExportFeeds(format))) + _, _ = w.Write([]byte(exporter.ExportFeeds(format))) } func (s *Server) HandleImport(w http.ResponseWriter, r *http.Request) { @@ -256,7 +256,7 @@ func (s *Server) HandleImport(w http.ResponseWriter, r *http.Request) { jsonError(w, "file required", http.StatusBadRequest) return } - defer file.Close() + defer func() { _ = file.Close() }() err = importer.ImportFeeds(format, file) if err != nil { -- cgit v1.2.3