fix: resolve golangci-lint errcheck warnings
Some checks failed
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Release (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:43 -05:00
parent 32b7420c34
commit b4ed7dd5b4

View File

@@ -28,26 +28,26 @@ func newVoiceMocks(t *testing.T) *voiceMocks {
m := &voiceMocks{}
m.STT = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(map[string]string{"text": "What is the weather today?"})
_ = json.NewEncoder(w).Encode(map[string]string{"text": "What is the weather today?"})
}))
t.Cleanup(m.STT.Close)
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{{"embedding": []float64{0.5, 0.6, 0.7}}},
})
}))
t.Cleanup(m.Embeddings.Close)
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{{"index": 0, "relevance_score": 0.88}},
})
}))
t.Cleanup(m.Reranker.Close)
m.LLM = 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{
"choices": []map[string]any{
{"message": map[string]any{"content": "Sunny with a high of 72."}},
},
@@ -56,7 +56,7 @@ func newVoiceMocks(t *testing.T) *voiceMocks {
t.Cleanup(m.LLM.Close)
m.TTS = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write(make([]byte, 8000)) // simulated audio
_, _ = w.Write(make([]byte, 8000)) // simulated audio
}))
t.Cleanup(m.TTS.Close)
@@ -122,7 +122,7 @@ func TestVoicePipeline_FullFlow(t *testing.T) {
func TestVoicePipeline_STTFailure(t *testing.T) {
failSTT := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(500)
w.Write([]byte("model not loaded"))
_, _ = w.Write([]byte("model not loaded"))
}))
defer failSTT.Close()
@@ -136,7 +136,7 @@ func TestVoicePipeline_STTFailure(t *testing.T) {
func TestVoicePipeline_TTSLargeResponse(t *testing.T) {
// TTS that returns 1 MB of audio.
bigTTS := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write(make([]byte, 1<<20))
_, _ = w.Write(make([]byte, 1<<20))
}))
defer bigTTS.Close()
@@ -156,17 +156,17 @@ func TestVoicePipeline_TTSLargeResponse(t *testing.T) {
func BenchmarkVoicePipeline_Full(b *testing.B) {
sttSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`{"text":"hello"}`))
_, _ = w.Write([]byte(`{"text":"hello"}`))
}))
defer sttSrv.Close()
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()
ttsSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write(make([]byte, 4000))
_, _ = w.Write(make([]byte, 4000))
}))
defer ttsSrv.Close()
@@ -178,8 +178,8 @@ func BenchmarkVoicePipeline_Full(b *testing.B) {
b.ResetTimer()
for b.Loop() {
stt.Transcribe(ctx, audio, "en")
llm.Generate(ctx, "question", "", "")
tts.Synthesize(ctx, "answer", "en", "")
_, _ = stt.Transcribe(ctx, audio, "en")
_, _ = llm.Generate(ctx, "question", "", "")
_, _ = tts.Synthesize(ctx, "answer", "en", "")
}
}