fix: resolve golangci-lint errcheck warnings
Some checks failed
CI / Lint (push) Failing after 57s
CI / Test (push) Failing after 1m22s
CI / Release (push) Has been cancelled
CI / Docker Build & Push (push) Has been cancelled
CI / Notify (push) Has been cancelled

- Add error checks for unchecked return values (errcheck)
- Remove unused struct fields (unused)
- Fix gofmt formatting issues
This commit is contained in:
2026-02-20 08:45:24 -05:00
parent c27d192705
commit b48fbb424d

View File

@@ -30,7 +30,7 @@ t.Helper()
m := &mockBackends{} m := &mockBackends{}
m.Embeddings = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { m.Embeddings = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(map[string]any{ _ = json.NewEncoder(w).Encode(map[string]any{
"data": []map[string]any{ "data": []map[string]any{
{"embedding": []float64{0.1, 0.2, 0.3, 0.4}}, {"embedding": []float64{0.1, 0.2, 0.3, 0.4}},
}, },
@@ -39,7 +39,7 @@ json.NewEncoder(w).Encode(map[string]any{
t.Cleanup(m.Embeddings.Close) t.Cleanup(m.Embeddings.Close)
m.Reranker = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { m.Reranker = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(map[string]any{ _ = json.NewEncoder(w).Encode(map[string]any{
"results": []map[string]any{ "results": []map[string]any{
{"index": 0, "relevance_score": 0.95}, {"index": 0, "relevance_score": 0.95},
}, },
@@ -49,8 +49,8 @@ t.Cleanup(m.Reranker.Close)
m.LLM = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { m.LLM = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var req map[string]any var req map[string]any
json.NewDecoder(r.Body).Decode(&req) _ = json.NewDecoder(r.Body).Decode(&req)
json.NewEncoder(w).Encode(map[string]any{ _ = json.NewEncoder(w).Encode(map[string]any{
"choices": []map[string]any{ "choices": []map[string]any{
{"message": map[string]any{ {"message": map[string]any{
"content": "Paris is the capital of France.", "content": "Paris is the capital of France.",
@@ -61,7 +61,7 @@ json.NewEncoder(w).Encode(map[string]any{
t.Cleanup(m.LLM.Close) t.Cleanup(m.LLM.Close)
m.TTS = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { m.TTS = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte{0xDE, 0xAD, 0xBE, 0xEF}) _, _ = w.Write([]byte{0xDE, 0xAD, 0xBE, 0xEF})
})) }))
t.Cleanup(m.TTS.Close) t.Cleanup(m.TTS.Close)
@@ -148,7 +148,7 @@ func TestChatPipeline_LLMTimeout(t *testing.T) {
// Simulate slow LLM. // Simulate slow LLM.
slow := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { slow := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
time.Sleep(200 * time.Millisecond) time.Sleep(200 * time.Millisecond)
json.NewEncoder(w).Encode(map[string]any{ _ = json.NewEncoder(w).Encode(map[string]any{
"choices": []map[string]any{ "choices": []map[string]any{
{"message": map[string]any{"content": "late response"}}, {"message": map[string]any{"content": "late response"}},
}, },
@@ -204,7 +204,7 @@ func TestChatPipeline_TypedDecoding(t *testing.T) {
func BenchmarkChatPipeline_LLMOnly(b *testing.B) { func BenchmarkChatPipeline_LLMOnly(b *testing.B) {
llmSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { llmSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`{"choices":[{"message":{"content":"answer"}}]}`)) _, _ = w.Write([]byte(`{"choices":[{"message":{"content":"answer"}}]}`))
})) }))
defer llmSrv.Close() defer llmSrv.Close()
@@ -213,23 +213,23 @@ ctx := context.Background()
b.ResetTimer() b.ResetTimer()
for b.Loop() { for b.Loop() {
llm.Generate(ctx, "question", "", "") _, _ = llm.Generate(ctx, "question", "", "")
} }
} }
func BenchmarkChatPipeline_RAGFlow(b *testing.B) { func BenchmarkChatPipeline_RAGFlow(b *testing.B) {
embedSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { embedSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`{"data":[{"embedding":[0.1,0.2]}]}`)) _, _ = w.Write([]byte(`{"data":[{"embedding":[0.1,0.2]}]}`))
})) }))
defer embedSrv.Close() defer embedSrv.Close()
rerankSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { rerankSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`{"results":[{"index":0,"relevance_score":0.9}]}`)) _, _ = w.Write([]byte(`{"results":[{"index":0,"relevance_score":0.9}]}`))
})) }))
defer rerankSrv.Close() defer rerankSrv.Close()
llmSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { llmSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`{"choices":[{"message":{"content":"answer"}}]}`)) _, _ = w.Write([]byte(`{"choices":[{"message":{"content":"answer"}}]}`))
})) }))
defer llmSrv.Close() defer llmSrv.Close()
@@ -240,8 +240,8 @@ ctx := context.Background()
b.ResetTimer() b.ResetTimer()
for b.Loop() { for b.Loop() {
embed.EmbedSingle(ctx, "question") _, _ = embed.EmbedSingle(ctx, "question")
rerank.Rerank(ctx, "question", []string{"doc1", "doc2"}, 2) _, _ = rerank.Rerank(ctx, "question", []string{"doc1", "doc2"}, 2)
llm.Generate(ctx, "question", "context", "") _, _ = llm.Generate(ctx, "question", "context", "")
} }
} }