Skip to content

Commit 4863450

Browse files
committed
fix: resolve lint errors, update Go to 1.26.3, and fix golangci-lint v2 config
1 parent c807c8e commit 4863450

9 files changed

Lines changed: 51 additions & 80 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ concurrency:
3232
cancel-in-progress: true
3333

3434
env:
35-
GO_VERSION: "1.26.1"
35+
GO_VERSION: "1.26.3"
3636

3737
jobs:
3838
# -------------------------------------------------------------------------

.golangci.yml

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,42 @@ linters:
1414
- bodyclose
1515
- unconvert
1616
- whitespace
17-
18-
linters-settings:
19-
errcheck:
20-
check-type-assertions: true
21-
check-blank: false
22-
govet:
23-
enable-all: true
24-
disable:
25-
- fieldalignment
26-
gocritic:
27-
enabled-tags:
28-
- diagnostic
29-
- performance
30-
disabled-checks:
31-
- hugeParam
32-
- rangeValCopy
33-
- appendAssign
34-
staticcheck:
35-
checks:
36-
- all
37-
- -SA1019
17+
settings:
18+
errcheck:
19+
check-type-assertions: true
20+
check-blank: false
21+
govet:
22+
enable-all: true
23+
disable:
24+
- fieldalignment
25+
gocritic:
26+
enabled-tags:
27+
- diagnostic
28+
- performance
29+
disabled-checks:
30+
- hugeParam
31+
- rangeValCopy
32+
- appendAssign
33+
staticcheck:
34+
checks:
35+
- all
36+
- -SA1019
37+
exclusions:
38+
paths:
39+
- .gomodcache
40+
- vendor
41+
rules:
42+
- path: _test\.go
43+
linters:
44+
- gocritic
45+
- noctx
46+
- bodyclose
47+
- errcheck
48+
- unused
49+
- path: cmd/
50+
linters:
51+
- noctx
3852

3953
issues:
4054
max-issues-per-linter: 0
4155
max-same-issues: 0
42-
exclude-dirs:
43-
- .gomodcache
44-
- vendor
45-
exclude-rules:
46-
- path: _test\.go
47-
linters:
48-
- gocritic
49-
- noctx
50-
- bodyclose
51-
- errcheck
52-
- path: cmd/
53-
linters:
54-
- noctx

auth/device_flow.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (df *DeviceFlow) RequestCode(ctx context.Context) (*DeviceCodeResponse, err
7272
if err != nil {
7373
return nil, err
7474
}
75-
defer resp.Body.Close()
75+
defer func() { _ = resp.Body.Close() }()
7676

7777
if resp.StatusCode != http.StatusOK {
7878
return nil, fmt.Errorf("device auth request failed: HTTP %d", resp.StatusCode)
@@ -132,7 +132,7 @@ func (df *DeviceFlow) exchangeCode(ctx context.Context, deviceCode string) (*Tok
132132
if err != nil {
133133
return nil, err
134134
}
135-
defer resp.Body.Close()
135+
defer func() { _ = resp.Body.Close() }()
136136

137137
var raw map[string]interface{}
138138
if err := json.NewDecoder(resp.Body).Decode(&raw); err != nil {
@@ -145,6 +145,8 @@ func (df *DeviceFlow) exchangeCode(ctx context.Context, deviceCode string) (*Tok
145145

146146
jsonData, _ := json.Marshal(raw)
147147
var token TokenResponse
148-
json.Unmarshal(jsonData, &token)
148+
if err := json.Unmarshal(jsonData, &token); err != nil {
149+
return nil, err
150+
}
149151
return &token, nil
150152
}

cmd/chat_stream.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,6 @@ func (m *chatModel) startStream() {
5656
}()
5757
}
5858

59-
// renderGlimmerVerb renders the spinner verb with a sweeping 3-color wave
60-
func renderGlimmerVerb(verb string, glimmerPos int) string {
61-
if len(verb) == 0 {
62-
return ""
63-
}
64-
// 3 colors: vivid orange, bright orange, warm amber
65-
colors := []string{"255;94;14", "255;140;50", "255;180;80"}
66-
runes := []rune(verb)
67-
68-
var b strings.Builder
69-
for i, r := range runes {
70-
// Wave: each char picks a color based on position + time, cycling 1→2→3→2→1→2→3...
71-
dist := abs((i+glimmerPos)%5 - 2)
72-
if dist == 0 {
73-
b.WriteString("\033[1;38;2;" + colors[0] + "m" + string(r))
74-
} else if dist == 1 {
75-
b.WriteString("\033[1;38;2;" + colors[1] + "m" + string(r))
76-
} else {
77-
b.WriteString("\033[1;38;2;" + colors[2] + "m" + string(r))
78-
}
79-
}
80-
b.WriteString("\033[0m")
81-
return b.String()
82-
}
83-
8459
func abs(x int) int {
8560
if x < 0 {
8661
return -x

tool/agent.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@ import (
55
"encoding/json"
66
"fmt"
77
"sync"
8-
"time"
98
)
109

11-
// backgroundCompletionTimeout is the maximum time to wait for background
12-
// sub-agents in a single background-completion cycle.
13-
const backgroundCompletionTimeout = 2 * time.Minute
14-
1510
type AgentTool struct{}
1611

1712
func (AgentTool) Name() string { return "Agent" }

tool/web_search_brave.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,7 @@ func (c *braveClient) search(ctx context.Context, query string, count int) ([]se
9797
if len(results) >= count {
9898
break
9999
}
100-
results = append(results, searchResult{
101-
Title: r.Title,
102-
URL: r.URL,
103-
Description: r.Description,
104-
})
100+
results = append(results, searchResult(r))
105101
}
106102

107103
return results, nil

trace/langfuse.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (c *LangfuseClient) Trace(ctx context.Context, ev TraceEvent) {
8181
c.mu.Unlock()
8282

8383
if shouldFlush {
84-
go c.Flush(ctx)
84+
go func() { _ = c.Flush(ctx) }()
8585
}
8686
}
8787

@@ -113,7 +113,7 @@ func (c *LangfuseClient) Flush(ctx context.Context) error {
113113
if err != nil {
114114
return err
115115
}
116-
resp.Body.Close()
116+
defer func() { _ = resp.Body.Close() }()
117117
if resp.StatusCode >= 400 {
118118
return fmt.Errorf("langfuse: HTTP %d", resp.StatusCode)
119119
}

trace/session_trace.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,12 @@ func (st *SessionTrace) FormatTree() string {
265265
// formatSpan recursively renders a span and its children into the builder.
266266
func formatSpan(b *strings.Builder, span *SessionSpan, prefix string, isLast bool, isRoot bool) {
267267
// Write the connector.
268-
if isRoot {
268+
switch {
269+
case isRoot:
269270
// No connector for the root span.
270-
} else if isLast {
271+
case isLast:
271272
b.WriteString(prefix + "└── ")
272-
} else {
273+
default:
273274
b.WriteString(prefix + "├── ")
274275
}
275276

@@ -282,7 +283,7 @@ func formatSpan(b *strings.Builder, span *SessionSpan, prefix string, isLast boo
282283
dur = time.Since(span.StartTime)
283284
}
284285
}
285-
b.WriteString(fmt.Sprintf("%s [%s]", span.Name, formatDuration(dur)))
286+
fmt.Fprintf(b, "%s [%s]", span.Name, formatDuration(dur))
286287

287288
// Write selected attributes inline.
288289
attrParts := formatInlineAttrs(span)

update/update.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package update
22

33
import (
4+
"context"
45
"encoding/json"
56
"fmt"
67
"io"
@@ -25,7 +26,7 @@ type ReleaseInfo struct {
2526

2627
// Check checks for available updates.
2728
func Check(currentVersion string) (*ReleaseInfo, error) {
28-
req, err := http.NewRequest("GET", updateURL, nil)
29+
req, err := http.NewRequestWithContext(context.Background(), "GET", updateURL, nil)
2930
if err != nil {
3031
return nil, err
3132
}

0 commit comments

Comments
 (0)