mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
fix: check all Close() return values for errcheck lint
Add explicit error discards (_ =) for Close() calls on network connections, SQL rows, and file handles across 28 files. Also add .golangci.yml with standard linter defaults to match CI configuration.
This commit is contained in:
@@ -124,7 +124,7 @@ func TestAPIServerStart(t *testing.T) {
|
||||
// This might fail if the server didn't start properly or port is blocked
|
||||
t.Logf("Failed to connect to server: %v", err)
|
||||
} else {
|
||||
defer resp.Body.Close()
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNotFound {
|
||||
t.Logf("Unexpected status code: %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ func (s *APIServer) ScreenShotGet(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "Image not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
defer func() { _ = file.Close() }()
|
||||
// Set content type header to image/jpeg
|
||||
w.Header().Set("Content-Type", "image/jpeg")
|
||||
// Copy the image content to the response writer
|
||||
@@ -390,7 +390,7 @@ func (s *APIServer) ScreenShot(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
result = Result{Code: "500"}
|
||||
}
|
||||
defer outputFile.Close()
|
||||
defer func() { _ = outputFile.Close() }()
|
||||
|
||||
// Encode the image and write it to the file
|
||||
err = jpeg.Encode(outputFile, img, &jpeg.Options{Quality: s.erupeConfig.Screenshots.UploadQuality})
|
||||
|
||||
Reference in New Issue
Block a user