Skip to content

Commit 25eb5f8

Browse files
gcmsgclaude
andcommitted
fix: suppress remaining errcheck warnings for golangci-lint v2
Add explicit error discards (_) for unchecked return values in HTTP response encoders, resp.Body.Close, json.Unmarshal, and otel shutdown calls across all non-test files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 333f392 commit 25eb5f8

File tree

9 files changed

+19
-19
lines changed

9 files changed

+19
-19
lines changed

cmd/peerclawd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,6 @@ func main() {
320320
if fedService != nil {
321321
_ = fedService.Close()
322322
}
323-
bridgeManager.Close()
323+
_ = bridgeManager.Close()
324324
logger.Info("PeerClaw gateway stopped")
325325
}

internal/bridge/a2a/adapter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func (a *Adapter) Handshake(ctx context.Context, card *agentcard.Card) error {
189189
if err != nil {
190190
return fmt.Errorf("a2a: fetch agent card: %w", err)
191191
}
192-
defer resp.Body.Close()
192+
defer func() { _ = resp.Body.Close() }()
193193

194194
if resp.StatusCode != http.StatusOK {
195195
return fmt.Errorf("a2a: agent card status %d", resp.StatusCode)

internal/bridge/a2a/handler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (a *Adapter) HandleAgentCard(w http.ResponseWriter, r *http.Request) {
147147
}
148148

149149
w.Header().Set("Content-Type", "application/json")
150-
json.NewEncoder(w).Encode(card)
150+
_ = json.NewEncoder(w).Encode(card)
151151
}
152152

153153
// HandleGetTask handles GET /a2a/tasks/{id}.
@@ -165,7 +165,7 @@ func (a *Adapter) HandleGetTask(w http.ResponseWriter, r *http.Request) {
165165
}
166166

167167
w.Header().Set("Content-Type", "application/json")
168-
json.NewEncoder(w).Encode(task)
168+
_ = json.NewEncoder(w).Encode(task)
169169
}
170170

171171
// KindNotification is used for checking parsed message kind.
@@ -179,12 +179,12 @@ func writeJSONRPCResult(w http.ResponseWriter, id any, result any) {
179179
return
180180
}
181181
w.Header().Set("Content-Type", "application/json")
182-
json.NewEncoder(w).Encode(resp)
182+
_ = json.NewEncoder(w).Encode(resp)
183183
}
184184

185185
func writeJSONRPCError(w http.ResponseWriter, id any, code int, message string) {
186186
resp := jsonrpc.NewErrorResponse(id, code, message)
187187
w.Header().Set("Content-Type", "application/json")
188188
w.WriteHeader(http.StatusOK) // JSON-RPC errors still use 200
189-
json.NewEncoder(w).Encode(resp)
189+
_ = json.NewEncoder(w).Encode(resp)
190190
}

internal/bridge/acp/adapter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (a *Adapter) Handshake(ctx context.Context, card *agentcard.Card) error {
153153
if err != nil {
154154
return fmt.Errorf("acp: fetch manifest: %w", err)
155155
}
156-
defer resp.Body.Close()
156+
defer func() { _ = resp.Body.Close() }()
157157

158158
if resp.StatusCode != http.StatusOK {
159159
return fmt.Errorf("acp: manifest status %d", resp.StatusCode)

internal/bridge/mcp/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ func writeMCPResult(w http.ResponseWriter, id any, result any) {
202202
return
203203
}
204204
w.Header().Set("Content-Type", "application/json")
205-
json.NewEncoder(w).Encode(resp)
205+
_ = json.NewEncoder(w).Encode(resp)
206206
}
207207

208208
func writeMCPError(w http.ResponseWriter, id any, code int, message string) {
209209
resp := jsonrpc.NewErrorResponse(id, code, message)
210210
w.Header().Set("Content-Type", "application/json")
211211
w.WriteHeader(http.StatusOK)
212-
json.NewEncoder(w).Encode(resp)
212+
_ = json.NewEncoder(w).Encode(resp)
213213
}

internal/observability/otel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func Init(ctx context.Context, cfg config.ObservabilityConfig, logger *slog.Logg
7373
otlpmetricgrpc.WithInsecure(),
7474
)
7575
if err != nil {
76-
tp.Shutdown(ctx)
76+
_ = tp.Shutdown(ctx)
7777
return nil, err
7878
}
7979

internal/registry/postgres.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,13 @@ func (s *PostgresStore) scanCardFromRows(rows *sql.Rows) (*agentcard.Card, error
354354
}
355355

356356
func (s *PostgresStore) unmarshalCard(card *agentcard.Card, caps, protos, authParams, meta, tags, skills, tools, status, transport string, regAt, hbAt time.Time) {
357-
json.Unmarshal([]byte(caps), &card.Capabilities)
358-
json.Unmarshal([]byte(protos), &card.Protocols)
359-
json.Unmarshal([]byte(authParams), &card.Auth.Params)
360-
json.Unmarshal([]byte(meta), &card.Metadata)
361-
json.Unmarshal([]byte(tags), &card.PeerClaw.Tags)
362-
json.Unmarshal([]byte(skills), &card.Skills)
363-
json.Unmarshal([]byte(tools), &card.Tools)
357+
_ = json.Unmarshal([]byte(caps), &card.Capabilities)
358+
_ = json.Unmarshal([]byte(protos), &card.Protocols)
359+
_ = json.Unmarshal([]byte(authParams), &card.Auth.Params)
360+
_ = json.Unmarshal([]byte(meta), &card.Metadata)
361+
_ = json.Unmarshal([]byte(tags), &card.PeerClaw.Tags)
362+
_ = json.Unmarshal([]byte(skills), &card.Skills)
363+
_ = json.Unmarshal([]byte(tools), &card.Tools)
364364
card.Status = agentcard.AgentStatus(status)
365365
card.Endpoint.Transport = protocol.Transport(transport)
366366
card.RegisteredAt = regAt

internal/server/dashboard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ func DashboardHandler() http.Handler {
5555
}
5656
w.Header().Set("Content-Type", "text/html; charset=utf-8")
5757
w.Header().Set("Cache-Control", "no-cache")
58-
w.Write(indexData)
58+
_, _ = w.Write(indexData)
5959
})
6060
}

internal/server/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ func (s *HTTPServer) handleFederationDiscover(w http.ResponseWriter, r *http.Req
584584
func (s *HTTPServer) jsonResponse(w http.ResponseWriter, status int, data any) {
585585
w.Header().Set("Content-Type", "application/json")
586586
w.WriteHeader(status)
587-
json.NewEncoder(w).Encode(data)
587+
_ = json.NewEncoder(w).Encode(data)
588588
}
589589

590590
func (s *HTTPServer) jsonError(w http.ResponseWriter, message string, status int) {

0 commit comments

Comments
 (0)