ScuttleBot

fix: gofmt and govet — format three files, check resp error before use

lmata 2026-04-03 00:28 trunk
Commit 336984bb60f6490aa319cba2e1738b18036e62d60ccab076d931d6fe65084ea4
--- docs/guide/adding-agents.md
+++ docs/guide/adding-agents.md
@@ -283,11 +283,11 @@
283283
284284
Each runtime stores its session data in a different location:
285285
286286
| Runtime | Session log location |
287287
|---------|---------------------|
288
-| Claude Code | Claude projects directory — JSONL files named by session UUID |
288
+| Claude Code | `~/.claude/projects/{cwd-hash}/` — JSONL files named by session UUID |
289289
| Codex | `~/.codex/sessions/{session-id}.jsonl` |
290290
| Gemini CLI | `~/.gemini/sessions/{session-id}.jsonl` |
291291
292292
To find the latest session file:
293293
294294
--- docs/guide/adding-agents.md
+++ docs/guide/adding-agents.md
@@ -283,11 +283,11 @@
283
284 Each runtime stores its session data in a different location:
285
286 | Runtime | Session log location |
287 |---------|---------------------|
288 | Claude Code | Claude projects directory — JSONL files named by session UUID |
289 | Codex | `~/.codex/sessions/{session-id}.jsonl` |
290 | Gemini CLI | `~/.gemini/sessions/{session-id}.jsonl` |
291
292 To find the latest session file:
293
294
--- docs/guide/adding-agents.md
+++ docs/guide/adding-agents.md
@@ -283,11 +283,11 @@
283
284 Each runtime stores its session data in a different location:
285
286 | Runtime | Session log location |
287 |---------|---------------------|
288 | Claude Code | `~/.claude/projects/{cwd-hash}/` — JSONL files named by session UUID |
289 | Codex | `~/.codex/sessions/{session-id}.jsonl` |
290 | Gemini CLI | `~/.gemini/sessions/{session-id}.jsonl` |
291
292 To find the latest session file:
293
294
--- internal/api/channels_topology.go
+++ internal/api/channels_topology.go
@@ -22,14 +22,14 @@
2222
Voice []string `json:"voice,omitempty"`
2323
Autojoin []string `json:"autojoin,omitempty"`
2424
}
2525
2626
type provisionChannelResponse struct {
27
- Channel string `json:"channel"`
28
- Type string `json:"type,omitempty"`
29
- Supervision string `json:"supervision,omitempty"`
30
- Autojoin []string `json:"autojoin,omitempty"`
27
+ Channel string `json:"channel"`
28
+ Type string `json:"type,omitempty"`
29
+ Supervision string `json:"supervision,omitempty"`
30
+ Autojoin []string `json:"autojoin,omitempty"`
3131
}
3232
3333
// handleProvisionChannel handles POST /v1/channels.
3434
// It provisions an IRC channel via ChanServ, applies the autojoin policy for
3535
// the channel's type, and returns the channel name, type, and supervision channel.
3636
--- internal/api/channels_topology.go
+++ internal/api/channels_topology.go
@@ -22,14 +22,14 @@
22 Voice []string `json:"voice,omitempty"`
23 Autojoin []string `json:"autojoin,omitempty"`
24 }
25
26 type provisionChannelResponse struct {
27 Channel string `json:"channel"`
28 Type string `json:"type,omitempty"`
29 Supervision string `json:"supervision,omitempty"`
30 Autojoin []string `json:"autojoin,omitempty"`
31 }
32
33 // handleProvisionChannel handles POST /v1/channels.
34 // It provisions an IRC channel via ChanServ, applies the autojoin policy for
35 // the channel's type, and returns the channel name, type, and supervision channel.
36
--- internal/api/channels_topology.go
+++ internal/api/channels_topology.go
@@ -22,14 +22,14 @@
22 Voice []string `json:"voice,omitempty"`
23 Autojoin []string `json:"autojoin,omitempty"`
24 }
25
26 type provisionChannelResponse struct {
27 Channel string `json:"channel"`
28 Type string `json:"type,omitempty"`
29 Supervision string `json:"supervision,omitempty"`
30 Autojoin []string `json:"autojoin,omitempty"`
31 }
32
33 // handleProvisionChannel handles POST /v1/channels.
34 // It provisions an IRC channel via ChanServ, applies the autojoin policy for
35 // the channel's type, and returns the channel name, type, and supervision channel.
36
--- internal/api/channels_topology_test.go
+++ internal/api/channels_topology_test.go
@@ -97,11 +97,14 @@
9797
9898
body, _ := json.Marshal(map[string]string{"name": "no-hash"})
9999
req, _ := http.NewRequest(http.MethodPost, srv.URL+"/v1/channels", bytes.NewReader(body))
100100
req.Header.Set("Authorization", "Bearer "+tok)
101101
req.Header.Set("Content-Type", "application/json")
102
- resp, _ := http.DefaultClient.Do(req)
102
+ resp, err := http.DefaultClient.Do(req)
103
+ if err != nil {
104
+ t.Fatalf("do: %v", err)
105
+ }
103106
defer resp.Body.Close()
104107
if resp.StatusCode != http.StatusBadRequest {
105108
t.Errorf("want 400, got %d", resp.StatusCode)
106109
}
107110
}
108111
--- internal/api/channels_topology_test.go
+++ internal/api/channels_topology_test.go
@@ -97,11 +97,14 @@
97
98 body, _ := json.Marshal(map[string]string{"name": "no-hash"})
99 req, _ := http.NewRequest(http.MethodPost, srv.URL+"/v1/channels", bytes.NewReader(body))
100 req.Header.Set("Authorization", "Bearer "+tok)
101 req.Header.Set("Content-Type", "application/json")
102 resp, _ := http.DefaultClient.Do(req)
 
 
 
103 defer resp.Body.Close()
104 if resp.StatusCode != http.StatusBadRequest {
105 t.Errorf("want 400, got %d", resp.StatusCode)
106 }
107 }
108
--- internal/api/channels_topology_test.go
+++ internal/api/channels_topology_test.go
@@ -97,11 +97,14 @@
97
98 body, _ := json.Marshal(map[string]string{"name": "no-hash"})
99 req, _ := http.NewRequest(http.MethodPost, srv.URL+"/v1/channels", bytes.NewReader(body))
100 req.Header.Set("Authorization", "Bearer "+tok)
101 req.Header.Set("Content-Type", "application/json")
102 resp, err := http.DefaultClient.Do(req)
103 if err != nil {
104 t.Fatalf("do: %v", err)
105 }
106 defer resp.Body.Close()
107 if resp.StatusCode != http.StatusBadRequest {
108 t.Errorf("want 400, got %d", resp.StatusCode)
109 }
110 }
111
--- internal/api/config_handlers_test.go
+++ internal/api/config_handlers_test.go
@@ -146,15 +146,15 @@
146146
func TestHandlePutConfigLogging(t *testing.T) {
147147
srv, store := newCfgTestServer(t)
148148
149149
update := map[string]any{
150150
"logging": map[string]any{
151
- "enabled": true,
152
- "dir": "./data/logs",
153
- "format": "jsonl",
154
- "rotation": "daily",
155
- "per_channel": true,
151
+ "enabled": true,
152
+ "dir": "./data/logs",
153
+ "format": "jsonl",
154
+ "rotation": "daily",
155
+ "per_channel": true,
156156
"max_age_days": 30,
157157
},
158158
}
159159
body, _ := json.Marshal(update)
160160
req, _ := http.NewRequest(http.MethodPut, srv.URL+"/v1/config", bytes.NewReader(body))
161161
--- internal/api/config_handlers_test.go
+++ internal/api/config_handlers_test.go
@@ -146,15 +146,15 @@
146 func TestHandlePutConfigLogging(t *testing.T) {
147 srv, store := newCfgTestServer(t)
148
149 update := map[string]any{
150 "logging": map[string]any{
151 "enabled": true,
152 "dir": "./data/logs",
153 "format": "jsonl",
154 "rotation": "daily",
155 "per_channel": true,
156 "max_age_days": 30,
157 },
158 }
159 body, _ := json.Marshal(update)
160 req, _ := http.NewRequest(http.MethodPut, srv.URL+"/v1/config", bytes.NewReader(body))
161
--- internal/api/config_handlers_test.go
+++ internal/api/config_handlers_test.go
@@ -146,15 +146,15 @@
146 func TestHandlePutConfigLogging(t *testing.T) {
147 srv, store := newCfgTestServer(t)
148
149 update := map[string]any{
150 "logging": map[string]any{
151 "enabled": true,
152 "dir": "./data/logs",
153 "format": "jsonl",
154 "rotation": "daily",
155 "per_channel": true,
156 "max_age_days": 30,
157 },
158 }
159 body, _ := json.Marshal(update)
160 req, _ := http.NewRequest(http.MethodPut, srv.URL+"/v1/config", bytes.NewReader(body))
161
--- pkg/client/topology.go
+++ pkg/client/topology.go
@@ -99,11 +99,13 @@
9999
if err != nil {
100100
return ChannelInfo{}, fmt.Errorf("topology: create channel: %w", err)
101101
}
102102
defer resp.Body.Close()
103103
if resp.StatusCode != http.StatusCreated {
104
- var apiErr struct{ Error string `json:"error"` }
104
+ var apiErr struct {
105
+ Error string `json:"error"`
106
+ }
105107
_ = json.NewDecoder(resp.Body).Decode(&apiErr)
106108
return ChannelInfo{}, fmt.Errorf("topology: create channel: %s", apiErr.Error)
107109
}
108110
var info ChannelInfo
109111
if err := json.NewDecoder(resp.Body).Decode(&info); err != nil {
@@ -128,11 +130,13 @@
128130
if err != nil {
129131
return fmt.Errorf("topology: drop channel: %w", err)
130132
}
131133
defer resp.Body.Close()
132134
if resp.StatusCode != http.StatusNoContent {
133
- var apiErr struct{ Error string `json:"error"` }
135
+ var apiErr struct {
136
+ Error string `json:"error"`
137
+ }
134138
_ = json.NewDecoder(resp.Body).Decode(&apiErr)
135139
return fmt.Errorf("topology: drop channel: %s", apiErr.Error)
136140
}
137141
return nil
138142
}
139143
--- pkg/client/topology.go
+++ pkg/client/topology.go
@@ -99,11 +99,13 @@
99 if err != nil {
100 return ChannelInfo{}, fmt.Errorf("topology: create channel: %w", err)
101 }
102 defer resp.Body.Close()
103 if resp.StatusCode != http.StatusCreated {
104 var apiErr struct{ Error string `json:"error"` }
 
 
105 _ = json.NewDecoder(resp.Body).Decode(&apiErr)
106 return ChannelInfo{}, fmt.Errorf("topology: create channel: %s", apiErr.Error)
107 }
108 var info ChannelInfo
109 if err := json.NewDecoder(resp.Body).Decode(&info); err != nil {
@@ -128,11 +130,13 @@
128 if err != nil {
129 return fmt.Errorf("topology: drop channel: %w", err)
130 }
131 defer resp.Body.Close()
132 if resp.StatusCode != http.StatusNoContent {
133 var apiErr struct{ Error string `json:"error"` }
 
 
134 _ = json.NewDecoder(resp.Body).Decode(&apiErr)
135 return fmt.Errorf("topology: drop channel: %s", apiErr.Error)
136 }
137 return nil
138 }
139
--- pkg/client/topology.go
+++ pkg/client/topology.go
@@ -99,11 +99,13 @@
99 if err != nil {
100 return ChannelInfo{}, fmt.Errorf("topology: create channel: %w", err)
101 }
102 defer resp.Body.Close()
103 if resp.StatusCode != http.StatusCreated {
104 var apiErr struct {
105 Error string `json:"error"`
106 }
107 _ = json.NewDecoder(resp.Body).Decode(&apiErr)
108 return ChannelInfo{}, fmt.Errorf("topology: create channel: %s", apiErr.Error)
109 }
110 var info ChannelInfo
111 if err := json.NewDecoder(resp.Body).Decode(&info); err != nil {
@@ -128,11 +130,13 @@
130 if err != nil {
131 return fmt.Errorf("topology: drop channel: %w", err)
132 }
133 defer resp.Body.Close()
134 if resp.StatusCode != http.StatusNoContent {
135 var apiErr struct {
136 Error string `json:"error"`
137 }
138 _ = json.NewDecoder(resp.Body).Decode(&apiErr)
139 return fmt.Errorf("topology: drop channel: %s", apiErr.Error)
140 }
141 return nil
142 }
143

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button