From 4d78ed534b776d1fe52f6e6138c0cd55cbaf55f4 Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Sun, 23 Aug 2026 16:49:32 +1000 Subject: [PATCH] Fix errcheck lint failures in CI golangci-lint errcheck flagged six unchecked error returns, failing the pr/test workflow's lint step and skipping tests. - Blank-assign hash writes in Row.Key and MarkHidden calls - Close response body via deferred func matching node-lookup convention - Read test request body with io.ReadAll instead of a single Body.Read --- internal/chlog/client.go | 4 ++-- internal/chlog/client_test.go | 6 +++--- main.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/chlog/client.go b/internal/chlog/client.go index 2451511..8d78da9 100644 --- a/internal/chlog/client.go +++ b/internal/chlog/client.go @@ -42,7 +42,7 @@ func (r Row) Time() time.Time { func (r Row) Key() uint64 { h := fnv.New64a() for _, s := range []string{r.Timestamp, r.Host, r.Source, r.Namespace, r.Pod, r.Container, r.Stream, r.Message} { - io.WriteString(h, s) + _, _ = io.WriteString(h, s) h.Write([]byte{0}) } return h.Sum64() @@ -81,7 +81,7 @@ func (c *Client) Run(ctx context.Context, q Query, fn func(Row) error) error { if err != nil { return fmt.Errorf("clickhouse request: %w", err) } - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { body, _ := io.ReadAll(io.LimitReader(resp.Body, 4096)) diff --git a/internal/chlog/client_test.go b/internal/chlog/client_test.go index bf18bea..ef3f24d 100644 --- a/internal/chlog/client_test.go +++ b/internal/chlog/client_test.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "io" "net/http" "net/http/httptest" "strconv" @@ -54,8 +55,7 @@ func (f *fakeCH) handler(t *testing.T) http.HandlerFunc { f.queries++ f.lastUser = r.Header.Get("X-ClickHouse-User") f.lastPass = r.Header.Get("X-ClickHouse-Key") - body := make([]byte, r.ContentLength) - r.Body.Read(body) + body, _ := io.ReadAll(r.Body) f.lastSQL = string(body) q := r.URL.Query() @@ -80,7 +80,7 @@ func (f *fakeCH) handler(t *testing.T) http.HandlerFunc { if limit >= 0 && sent >= limit { break } - enc.Encode(row) + _ = enc.Encode(row) sent++ } } diff --git a/main.go b/main.go index 34affc9..821b98c 100644 --- a/main.go +++ b/main.go @@ -141,8 +141,8 @@ func newTailCmd(use string) *cobra.Command { }, } cf.register(cmd, 0) - cmd.Flags().MarkHidden("until") - cmd.Flags().MarkHidden("limit") + _ = cmd.Flags().MarkHidden("until") + _ = cmd.Flags().MarkHidden("limit") return cmd }