From de4fa6ea90e86845a70447b47991cd26c232226c Mon Sep 17 00:00:00 2001 From: "Billy D." Date: Fri, 20 Feb 2026 08:45:25 -0500 Subject: [PATCH] fix: resolve golangci-lint errcheck warnings - Add error checks for unchecked return values (errcheck) - Remove unused struct fields (unused) - Fix gofmt formatting issues --- e2e_test.go | 18 +++++++++--------- main.go | 4 ++-- main_test.go | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/e2e_test.go b/e2e_test.go index 6805a8f..9eea37a 100644 --- a/e2e_test.go +++ b/e2e_test.go @@ -19,8 +19,8 @@ func TestSubmitArgoE2E_FullPayload(t *testing.T) { var receivedBody map[string]any ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - json.NewDecoder(r.Body).Decode(&receivedBody) - json.NewEncoder(w).Encode(map[string]any{ + _ = json.NewDecoder(r.Body).Decode(&receivedBody) + _ = json.NewEncoder(w).Encode(map[string]any{ "metadata": map[string]any{"name": "doc-ingest-xyz"}, }) })) @@ -72,8 +72,8 @@ func TestSubmitKubeflowE2E_FullPayload(t *testing.T) { var receivedBody map[string]any ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - json.NewDecoder(r.Body).Decode(&receivedBody) - json.NewEncoder(w).Encode(map[string]any{ + _ = json.NewDecoder(r.Body).Decode(&receivedBody) + _ = json.NewEncoder(w).Encode(map[string]any{ "run": map[string]any{"id": "kf-run-e2e-789"}, }) })) @@ -150,7 +150,7 @@ func TestSubmitArgoE2E_ConcurrentRequests(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { count.Add(1) - json.NewEncoder(w).Encode(map[string]any{ + _ = json.NewEncoder(w).Encode(map[string]any{ "metadata": map[string]any{"name": "concurrent-wf"}, }) })) @@ -184,7 +184,7 @@ func TestSubmitArgoE2E_ConcurrentRequests(t *testing.T) { func BenchmarkSubmitArgo(b *testing.B) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(`{"metadata":{"name":"bench-wf"}}`)) + _, _ = w.Write([]byte(`{"metadata":{"name":"bench-wf"}}`)) })) defer ts.Close() @@ -193,13 +193,13 @@ func BenchmarkSubmitArgo(b *testing.B) { b.ResetTimer() for b.Loop() { - submitArgo(ctx, ts.Client(), ts.URL, "ai-ml", "document-ingestion", params, "bench-req") + _, _ = submitArgo(ctx, ts.Client(), ts.URL, "ai-ml", "document-ingestion", params, "bench-req") } } func BenchmarkSubmitKubeflow(b *testing.B) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(`{"run":{"id":"bench-run"}}`)) + _, _ = w.Write([]byte(`{"run":{"id":"bench-run"}}`)) })) defer ts.Close() @@ -208,6 +208,6 @@ func BenchmarkSubmitKubeflow(b *testing.B) { b.ResetTimer() for b.Loop() { - submitKubeflow(ctx, ts.Client(), ts.URL, "rag-pipeline", params, "bench-req") + _, _ = submitKubeflow(ctx, ts.Client(), ts.URL, "rag-pipeline", params, "bench-req") } } diff --git a/main.go b/main.go index 26fa09e..f8dcbd0 100644 --- a/main.go +++ b/main.go @@ -151,7 +151,7 @@ func submitArgo(ctx context.Context, client *http.Client, host, namespace, templ if err != nil { return "", fmt.Errorf("argo request: %w", err) } - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() respBody, _ := io.ReadAll(resp.Body) if resp.StatusCode >= 400 { @@ -196,7 +196,7 @@ func submitKubeflow(ctx context.Context, client *http.Client, host, pipelineID s if err != nil { return "", fmt.Errorf("kubeflow request: %w", err) } - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() respBody, _ := io.ReadAll(resp.Body) if resp.StatusCode >= 400 { diff --git a/main_test.go b/main_test.go index 640964c..3fe4048 100644 --- a/main_test.go +++ b/main_test.go @@ -111,7 +111,7 @@ func TestSubmitArgo(t *testing.T) { } w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(map[string]any{ + _ = json.NewEncoder(w).Encode(map[string]any{ "metadata": map[string]any{"name": "document-ingestion-abc123"}, }) })) @@ -132,7 +132,7 @@ func TestSubmitArgo(t *testing.T) { func TestSubmitArgoError(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusBadRequest) - w.Write([]byte(`{"message":"bad request"}`)) + _, _ = w.Write([]byte(`{"message":"bad request"}`)) })) defer ts.Close() @@ -153,7 +153,7 @@ func TestSubmitKubeflow(t *testing.T) { } w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(map[string]any{ + _ = json.NewEncoder(w).Encode(map[string]any{ "run": map[string]any{"id": "kf-run-456"}, }) })) @@ -174,7 +174,7 @@ func TestSubmitKubeflow(t *testing.T) { func TestSubmitKubeflowError(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - w.Write([]byte("internal error")) + _, _ = w.Write([]byte("internal error")) })) defer ts.Close()