diff --git a/e2e_test.go b/e2e_test.go index 132fb42..9b5fa3d 100644 --- a/e2e_test.go +++ b/e2e_test.go @@ -150,12 +150,12 @@ func TestTranscriptionE2E_MockWhisper(t *testing.T) { if err != nil { t.Errorf("missing 'file' field: %v", err) } else { - file.Close() + _ = file.Close() } } w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(map[string]string{"text": "hello world"}) + _ = json.NewEncoder(w).Encode(map[string]string{"text": "hello world"}) })) defer whisperSrv.Close() @@ -166,20 +166,20 @@ func TestTranscriptionE2E_MockWhisper(t *testing.T) { if err != nil { t.Fatal(err) } - part.Write(make([]byte, 8000)) // simulated audio - writer.Close() + _, _ = part.Write(make([]byte, 8000)) // simulated audio + _ = writer.Close() resp, err := http.Post(whisperSrv.URL+"/v1/audio/transcriptions", writer.FormDataContentType(), &buf) if err != nil { t.Fatal(err) } - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() if resp.StatusCode != 200 { t.Errorf("status = %d", resp.StatusCode) } var result map[string]string - json.NewDecoder(resp.Body).Decode(&result) + _ = json.NewDecoder(resp.Body).Decode(&result) if result["text"] != "hello world" { t.Errorf("text = %q, want %q", result["text"], "hello world") } diff --git a/main.go b/main.go index 63bf3a2..d29f228 100644 --- a/main.go +++ b/main.go @@ -264,8 +264,8 @@ func main() { if err != nil { return "", err } - part.Write(audioData) - w.Close() + _, _ = part.Write(audioData) + _ = w.Close() req, err := http.NewRequestWithContext(ctx, http.MethodPost, whisperURL+"/v1/audio/transcriptions", &buf) if err != nil { @@ -277,7 +277,7 @@ func main() { if err != nil { return "", fmt.Errorf("whisper request: %w", err) } - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() body, _ := io.ReadAll(resp.Body) if resp.StatusCode >= 400 { @@ -335,7 +335,7 @@ func main() { State: state, } packed, _ := msgpack.Marshal(result) - nc.Conn().Publish(fmt.Sprintf("%s.%s", transcriptionSubjectPrefix, sessionID), packed) + _ = nc.Conn().Publish(fmt.Sprintf("%s.%s", transcriptionSubjectPrefix, sessionID), packed) slog.Info("published transcription", "session", sessionID, "seq", seq) } @@ -448,7 +448,7 @@ func main() { SpeakerID: buffer.speakerID, } packed, _ := msgpack.Marshal(interruptMsg) - nc.Conn().Publish(fmt.Sprintf("%s.%s", transcriptionSubjectPrefix, sessionID), packed) + _ = nc.Conn().Publish(fmt.Sprintf("%s.%s", transcriptionSubjectPrefix, sessionID), packed) slog.Info("published interrupt", "session", sessionID) buffer.setState(stateListening) } diff --git a/main_test.go b/main_test.go index 729cadf..80e00f1 100644 --- a/main_test.go +++ b/main_test.go @@ -155,7 +155,7 @@ func TestTranscribeHTTP(t *testing.T) { t.Errorf("expected POST, got %s", r.Method) } w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(map[string]string{"text": "hello world"}) + _ = json.NewEncoder(w).Encode(map[string]string{"text": "hello world"}) })) defer ts.Close() @@ -164,7 +164,7 @@ func TestTranscribeHTTP(t *testing.T) { if err != nil { t.Fatal(err) } - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() if resp.StatusCode != 200 { t.Errorf("status = %d", resp.StatusCode) }