Fix errcheck lint failures in CI
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful

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
This commit is contained in:
2026-08-23 16:49:32 +10:00
parent 415bf0cce1
commit 4d78ed534b
3 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -42,7 +42,7 @@ func (r Row) Time() time.Time {
func (r Row) Key() uint64 { func (r Row) Key() uint64 {
h := fnv.New64a() h := fnv.New64a()
for _, s := range []string{r.Timestamp, r.Host, r.Source, r.Namespace, r.Pod, r.Container, r.Stream, r.Message} { 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}) h.Write([]byte{0})
} }
return h.Sum64() return h.Sum64()
@@ -81,7 +81,7 @@ func (c *Client) Run(ctx context.Context, q Query, fn func(Row) error) error {
if err != nil { if err != nil {
return fmt.Errorf("clickhouse request: %w", err) return fmt.Errorf("clickhouse request: %w", err)
} }
defer resp.Body.Close() defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(io.LimitReader(resp.Body, 4096)) body, _ := io.ReadAll(io.LimitReader(resp.Body, 4096))
+3 -3
View File
@@ -4,6 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"strconv" "strconv"
@@ -54,8 +55,7 @@ func (f *fakeCH) handler(t *testing.T) http.HandlerFunc {
f.queries++ f.queries++
f.lastUser = r.Header.Get("X-ClickHouse-User") f.lastUser = r.Header.Get("X-ClickHouse-User")
f.lastPass = r.Header.Get("X-ClickHouse-Key") f.lastPass = r.Header.Get("X-ClickHouse-Key")
body := make([]byte, r.ContentLength) body, _ := io.ReadAll(r.Body)
r.Body.Read(body)
f.lastSQL = string(body) f.lastSQL = string(body)
q := r.URL.Query() q := r.URL.Query()
@@ -80,7 +80,7 @@ func (f *fakeCH) handler(t *testing.T) http.HandlerFunc {
if limit >= 0 && sent >= limit { if limit >= 0 && sent >= limit {
break break
} }
enc.Encode(row) _ = enc.Encode(row)
sent++ sent++
} }
} }
+2 -2
View File
@@ -141,8 +141,8 @@ func newTailCmd(use string) *cobra.Command {
}, },
} }
cf.register(cmd, 0) cf.register(cmd, 0)
cmd.Flags().MarkHidden("until") _ = cmd.Flags().MarkHidden("until")
cmd.Flags().MarkHidden("limit") _ = cmd.Flags().MarkHidden("limit")
return cmd return cmd
} }