From f775c2f67e605a6eb2f121c4f9c907c935f2c28b Mon Sep 17 00:00:00 2001 From: Daniel Arroyo Date: Thu, 30 Jul 2026 17:20:34 -0400 Subject: [PATCH] Fix golangci-lint errcheck and unused errors - manager.go: add _ = to syscall.Kill and proc.Signal calls (6 fixes) - chat.go: add _ = to c.Writer.WriteString calls (9 fixes) - webhook.go: remove unused webhookSecret field --- internal/api/handlers/chat.go | 18 +++++++++--------- internal/llama/manager.go | 12 ++++++------ internal/quota/webhook.go | 5 ++--- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/internal/api/handlers/chat.go b/internal/api/handlers/chat.go index 14e6f79..25f6463 100644 --- a/internal/api/handlers/chat.go +++ b/internal/api/handlers/chat.go @@ -180,19 +180,19 @@ func (h *ChatHandler) handleStream(c *gin.Context, apiKey *db.ApiKey, req ChatCo completionTokens += len(resp.Choices[0].Delta.Content) / 4 // Write SSE - c.Writer.WriteString("data: ") - c.Writer.WriteString("{\"id\":\"chatcmpl-1\",\"object\":\"chat.completion.chunk\",\"created\":") - c.Writer.WriteString(formatInt(resp.Created)) - c.Writer.WriteString(",\"model\":\"") - c.Writer.WriteString(resp.Model) - c.Writer.WriteString("\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"") - c.Writer.WriteString(escapeJSON(resp.Choices[0].Delta.Content)) - c.Writer.WriteString("\"}}]}\n\n") + _, _ = c.Writer.WriteString("data: ") + _, _ = c.Writer.WriteString("{\"id\":\"chatcmpl-1\",\"object\":\"chat.completion.chunk\",\"created\":") + _, _ = c.Writer.WriteString(formatInt(resp.Created)) + _, _ = c.Writer.WriteString(",\"model\":\"") + _, _ = c.Writer.WriteString(resp.Model) + _, _ = c.Writer.WriteString("\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"") + _, _ = c.Writer.WriteString(escapeJSON(resp.Choices[0].Delta.Content)) + _, _ = c.Writer.WriteString("\"}}]}\n\n") flusher.Flush() case err := <-errCh: h.logUsage(c, apiKey, req.Model, promptTokens, completionTokens, totalTokens, "error", start) - c.Writer.WriteString("data: [DONE]\n\n") + _, _ = c.Writer.WriteString("data: [DONE]\n\n") flusher.Flush() if err != nil { slog.Error("stream error", "error", err) diff --git a/internal/llama/manager.go b/internal/llama/manager.go index 787d434..4060d77 100644 --- a/internal/llama/manager.go +++ b/internal/llama/manager.go @@ -92,14 +92,14 @@ func (m *Manager) Stop() { pgid, err := syscall.Getpgid(m.proc.Process.Pid) if err == nil { - syscall.Kill(-pgid, syscall.SIGTERM) + _ = syscall.Kill(-pgid, syscall.SIGTERM) } else { - m.proc.Process.Signal(syscall.SIGTERM) + _ = m.proc.Process.Signal(syscall.SIGTERM) } <-ctx.Done() if m.proc.ProcessState == nil { - syscall.Kill(-pgid, syscall.SIGKILL) + _ = syscall.Kill(-pgid, syscall.SIGKILL) } } @@ -256,9 +256,9 @@ func (m *Manager) terminateProcess() { pgid, err := syscall.Getpgid(m.proc.Process.Pid) if err == nil { - syscall.Kill(-pgid, syscall.SIGTERM) + _ = syscall.Kill(-pgid, syscall.SIGTERM) } else { - m.proc.Process.Signal(syscall.SIGTERM) + _ = m.proc.Process.Signal(syscall.SIGTERM) } done := make(chan error, 1) @@ -269,7 +269,7 @@ func (m *Manager) terminateProcess() { select { case <-ctx.Done(): if pgid, err := syscall.Getpgid(m.proc.Process.Pid); err == nil { - syscall.Kill(-pgid, syscall.SIGKILL) + _ = syscall.Kill(-pgid, syscall.SIGKILL) } case <-done: } diff --git a/internal/quota/webhook.go b/internal/quota/webhook.go index 709a614..f689ef9 100644 --- a/internal/quota/webhook.go +++ b/internal/quota/webhook.go @@ -30,9 +30,8 @@ type WebhookPayload struct { } type WebhookService struct { - db *gorm.DB - client *http.Client - webhookSecret string + db *gorm.DB + client *http.Client } func NewWebhookService(db *gorm.DB) *WebhookService {