Fix all linter issues: errcheck, staticcheck, and unused code

- Fix critical scanner.go bug: ineffective break in select (SA4011)
  Use labeled break to properly exit loop on context cancellation

- Add error checking for all file.Close() and resp.Body.Close()
  Prevent resource leaks in loader, onvif_simple, and tester

- Add error checking for fmt.Sscanf() calls in tester.go
  Prevent silent parse failures for FPS and bitrate extraction

- Add error checking for all SSE streamWriter calls
  Explicit ignore with _ = for SendJSON and SendError

- Remove unused sync.RWMutex field from SearchEngine

- Refactor if/else to switch for CodecType (staticcheck QF1003)
  More idiomatic Go code in stream tester

All 20 linter issues resolved. Code compiles and runs correctly.
This commit is contained in:
eduard256
2025-11-12 11:17:12 +03:00
parent 94f94a9f8c
commit 86a8fb36d5
7 changed files with 32 additions and 31 deletions
+2 -2
View File
@@ -103,7 +103,7 @@ func (h *DiscoverHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
result, err := h.scanner.Scan(r.Context(), req, streamWriter)
if err != nil {
h.logger.Error("discovery failed", err)
streamWriter.SendError(err)
_ = streamWriter.SendError(err)
return
}
@@ -126,5 +126,5 @@ func (h *DiscoverHandler) sendErrorResponse(w http.ResponseWriter, message strin
"code": statusCode,
}
json.NewEncoder(w).Encode(response)
_ = json.NewEncoder(w).Encode(response)
}