fix(lint): satisfy errcheck for io.Copy, json.Encode, Body.Close, deferred Close
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -47,9 +47,9 @@ func main() {
|
|||||||
fmt.Fprintf(os.Stderr, "bridge: request failed: %v\n", err)
|
fmt.Fprintf(os.Stderr, "bridge: request failed: %v\n", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
io.Copy(os.Stdout, resp.Body)
|
_, _ = io.Copy(os.Stdout, resp.Body)
|
||||||
resp.Body.Close()
|
_ = resp.Body.Close()
|
||||||
os.Stdout.Write([]byte("\n"))
|
_, _ = os.Stdout.Write([]byte("\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := scanner.Err(); err != nil {
|
if err := scanner.Err(); err != nil {
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(response{
|
_ = json.NewEncoder(w).Encode(response{
|
||||||
JSONRPC: "2.0",
|
JSONRPC: "2.0",
|
||||||
ID: req.ID,
|
ID: req.ID,
|
||||||
Result: result,
|
Result: result,
|
||||||
@@ -90,7 +90,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func writeError(w http.ResponseWriter, id any, code int, msg string) {
|
func writeError(w http.ResponseWriter, id any, code int, msg string) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(response{
|
_ = json.NewEncoder(w).Encode(response{
|
||||||
JSONRPC: "2.0",
|
JSONRPC: "2.0",
|
||||||
ID: id,
|
ID: id,
|
||||||
Error: &rpcError{Code: code, Message: msg},
|
Error: &rpcError{Code: code, Message: msg},
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ func Read(sessionsDir, sessionID string) ([]Entry, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("open session log: %w", err)
|
return nil, fmt.Errorf("open session log: %w", err)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close() //nolint:errcheck
|
||||||
|
|
||||||
var entries []Entry
|
var entries []Entry
|
||||||
scanner := bufio.NewScanner(f)
|
scanner := bufio.NewScanner(f)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func TestHandle_BrainQuery_CallsIngestServer(t *testing.T) {
|
|||||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
assert.Equal(t, "/query", r.URL.Path)
|
assert.Equal(t, "/query", r.URL.Path)
|
||||||
called = true
|
called = true
|
||||||
json.NewEncoder(w).Encode(map[string]any{
|
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||||
"results": []map[string]any{
|
"results": []map[string]any{
|
||||||
{"path": "wiki/concepts/tdd.md", "title": "TDD", "excerpt": "Test-driven development.", "score": 3},
|
{"path": "wiki/concepts/tdd.md", "title": "TDD", "excerpt": "Test-driven development.", "score": 3},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user