Skip to content

Commit a7fc4d8

Browse files
committed
Lint stuff for golangci-lint
1 parent 6a0235c commit a7fc4d8

35 files changed

Lines changed: 568 additions & 501 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
cache: 'npm'
6666
- run: npm ci # required for esbuild
6767
- name: install golangci-lint
68-
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.1
68+
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.7.2
6969
- name: install godotenv
7070
run: go install github.com/joho/godotenv/cmd/godotenv
7171
- run: make lint-server

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ The application includes pluggable services for:
122122
3. **Docker** - PostgreSQL and local SMTP (MailHog)
123123
4. **Air** - Go hot reload: `go install github.com/cosmtrek/air`
124124
5. **Godotenv** - Environment loading: `go install github.com/joho/godotenv/cmd/godotenv`
125-
6. **golangci-lint** - Go linting: `go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1`
125+
6. **golangci-lint** - Go linting: `go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.2`
126126

127127
**Environment Setup:**
128128

app/cmd/ping.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func RunPing() int {
3535
return 1
3636
}
3737

38-
defer resp.Body.Close()
38+
defer func() { _ = resp.Body.Close() }()
3939
if resp.StatusCode >= 400 {
4040
fmt.Printf("Request failed with status code: %d\n", resp.StatusCode)
4141
return 1

app/cmd/signals_unix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func handleExtraSignal(s os.Signal, e *web.Engine) int {
2424
_ = pprof.Lookup("goroutine").WriteTo(buf, 1)
2525
_ = pprof.Lookup("heap").WriteTo(buf, 1)
2626
buf.WriteString("\n")
27-
buf.WriteString(fmt.Sprintf("# Worker Queue: %d\n", e.Worker().Length()))
28-
buf.WriteString(fmt.Sprintf("# Num Goroutines: %d\n", runtime.NumGoroutine()))
27+
fmt.Fprintf(buf, "# Worker Queue: %d\n", e.Worker().Length())
28+
fmt.Fprintf(buf, "# Num Goroutines: %d\n", runtime.NumGoroutine())
2929
println(buf.String())
3030
}
3131
return -1

app/const.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package app
33
import "errors"
44

55
// ErrNotFound represents an object not found error
6-
var ErrNotFound = errors.New("Object not found")
6+
var ErrNotFound = errors.New("object not found")
77

88
// InvitePlaceholder represents the placeholder used by members to invite other users
99
var InvitePlaceholder = "%invite%"

app/handlers/apiv1/invite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func SendSampleInvite() web.HandlerFunc {
2323
}
2424

2525
if c.User().Email != "" {
26-
action.Message = strings.Replace(action.Message, app.InvitePlaceholder, "*[the link to join will be here]*", -1)
26+
action.Message = strings.ReplaceAll(action.Message, app.InvitePlaceholder, "*[the link to join will be here]*")
2727
to := dto.NewRecipient(c.User().Name, c.User().Email, dto.Props{
2828
"subject": action.Subject,
2929
"message": markdown.Full(action.Message, true),

app/handlers/apiv1/post_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,10 @@ func TestCreatePostHandler_WithPublicTagAndPrivateTagAsCollaborator(t *testing.T
214214

215215
tagAssignments := make([]*cmd.AssignTag, 2)
216216
bus.AddHandler(func(ctx context.Context, c *cmd.AssignTag) error {
217-
if c.Tag.Slug == "public_tag" {
217+
switch c.Tag.Slug {
218+
case "public_tag":
218219
tagAssignments[0] = c
219-
} else if c.Tag.Slug == "private_tag" {
220+
case "private_tag":
220221
tagAssignments[1] = c
221222
}
222223
return nil

app/handlers/notification_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,22 @@ func TestReadNotificationHandler(t *testing.T) {
5555
not2 := &entity.Notification{ID: 2, Link: "/def"}
5656

5757
bus.AddHandler(func(ctx context.Context, q *query.GetNotificationByID) error {
58-
if q.ID == 1 {
58+
switch q.ID {
59+
case 1:
5960
q.Result = not1
60-
} else if q.ID == 2 {
61+
case 2:
6162
q.Result = not2
62-
} else {
63+
default:
6364
q.Result = nil
6465
}
6566
return nil
6667
})
6768

6869
bus.AddHandler(func(ctx context.Context, c *cmd.MarkNotificationAsRead) error {
69-
if c.ID == 1 {
70+
switch c.ID {
71+
case 1:
7072
not1.Read = true
71-
} else if c.ID == 2 {
73+
case 2:
7274
not2.Read = true
7375
}
7476
return nil

app/jobs/job.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func (j fiderJob) Run() {
5353

5454
// Jobs should take at least 1sec before unlocking to avoid double execution
5555
if elapsedMs <= 1000 {
56-
waitMs := time.Duration(1000 - elapsedMs)
57-
time.Sleep(waitMs * time.Millisecond)
56+
wait := time.Duration(1000 - elapsedMs)
57+
time.Sleep(wait * time.Millisecond)
5858
}
5959
unlock()
6060
}

app/middlewares/compress.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func Compress() web.MiddlewareFunc {
3434
}
3535

3636
err := next(c)
37-
gw.Close()
37+
_ = gw.Close()
3838
return err
3939
}
4040
return next(c)

0 commit comments

Comments
 (0)