Skip to content

Commit f1abbb1

Browse files
committed
chore: add golangci lint
1 parent f486499 commit f1abbb1

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

.golangci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: "2"
2+
linters:
3+
enable:
4+
- exhaustive
5+
settings:
6+
exhaustive:
7+
check:
8+
- "switch"
9+
- "map"
10+
staticcheck:
11+
checks:
12+
- "-QF1001" # disable "could apply De Morgan's law"

cmd/attach/attach.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ func ReadScreenOverHTTP(ctx context.Context, url string, ch chan<- httpapi.Scree
8080
if err != nil {
8181
return xerrors.Errorf("failed to do request: %w", err)
8282
}
83-
defer res.Body.Close()
83+
defer func() {
84+
_ = res.Body.Close()
85+
}()
8486

8587
for ev, err := range sse.Read(res.Body, &sse.ReadConfig{
8688
// 256KB: screen can be big. The default terminal size is 80x1000,
@@ -115,7 +117,9 @@ func WriteRawInputOverHTTP(ctx context.Context, url string, msg string) error {
115117
if err != nil {
116118
return xerrors.Errorf("failed to do request: %w", err)
117119
}
118-
defer res.Body.Close()
120+
defer func() {
121+
_ = res.Body.Close()
122+
}()
119123
if res.StatusCode != http.StatusOK {
120124
return xerrors.Errorf("failed to write raw input: %w", errors.New(res.Status))
121125
}
@@ -132,7 +136,9 @@ func runAttach(remoteUrl string) error {
132136
if err != nil {
133137
return xerrors.Errorf("failed to make raw: %w", err)
134138
}
135-
defer term.Restore(stdin, oldState)
139+
defer func() {
140+
_ = term.Restore(stdin, oldState)
141+
}()
136142

137143
stdinWriter := &ChannelWriter{
138144
ch: make(chan []byte, 4096),

lib/httpapi/embed.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ func FileServerWithIndexFallback(chatBasePath string) http.Handler {
8787
// Try to serve the file directly
8888
f, err := chatFS.Open(trimmedPath)
8989
if err == nil {
90-
defer f.Close()
90+
defer func() {
91+
_ = f.Close()
92+
}()
9193
fileServer.ServeHTTP(w, r)
9294
return
9395
}

lib/httpapi/server_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ func TestOpenAPISchema(t *testing.T) {
5555
if err != nil {
5656
t.Fatalf("failed to open disk schema: %s", err)
5757
}
58-
defer diskSchemaFile.Close()
58+
defer func() {
59+
_ = diskSchemaFile.Close()
60+
}()
5961

6062
diskSchemaBytes, err := io.ReadAll(diskSchemaFile)
6163
if err != nil {

lib/screentracker/conversation_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func TestMessages(t *testing.T) {
186186
assert.Equal(t, []st.ConversationMessage{
187187
agentMsg(0, "1"),
188188
}, msgs)
189-
nowWrapper.Time = nowWrapper.Time.Add(1 * time.Second)
189+
nowWrapper.Time = nowWrapper.Add(1 * time.Second)
190190
c.AddSnapshot("1")
191191
assert.Equal(t, msgs, c.Messages())
192192
})

0 commit comments

Comments
 (0)