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
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user