Skip to content

Commit 3dc1fb9

Browse files
committed
🚨 add lint
1 parent 966151e commit 3dc1fb9

9 files changed

Lines changed: 38 additions & 15 deletions

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515

16+
- name: lint
17+
uses: golangci/golangci-lint-action@v8
18+
1619
- name: Set up Docker Buildx
1720
uses: docker/setup-buildx-action@v3
1821

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.env
22
build/
33
*.db
4-
help-the-stars
4+
help-the-stars
5+
.cache/

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,3 @@ Create migration
7474
```bash
7575
docker run -v $(pwd)/migrations:/migrations --network host migrate/migrate -path=/migrations -database "sqlite://db/help-the-stars.db" create -ext sql -dir /migrations -seq MIGRATION_NAME
7676
```
77-
78-
## TODO
79-
80-
- [ ] lint go/docker

internal/datacontroller.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ func (d *DataController) Worker() {
7474

7575
func (d *DataController) GetAndSaveIssues() {
7676

77-
d.queries.TaskDataInProgress(d.ctx)
77+
err := d.queries.TaskDataInProgress(d.ctx)
78+
79+
if err != nil {
80+
log.Fatal(err)
81+
}
7882

7983
log.Info("Loading issues...")
8084
data, err := GetStaredRepos(50)
@@ -86,7 +90,10 @@ func (d *DataController) GetAndSaveIssues() {
8690

8791
for i := 0; i < len(expired); i++ {
8892
log.Info("Delete an issue ", expired[i].Url)
89-
d.queries.DeleteIssue(d.ctx, expired[i].Url)
93+
delErr := d.queries.DeleteIssue(d.ctx, expired[i].Url)
94+
if delErr != nil {
95+
log.Error("Error deleting issue", delErr)
96+
}
9097
}
9198

9299
if d.matrixClient != nil {
@@ -99,8 +106,12 @@ func (d *DataController) GetAndSaveIssues() {
99106
for i := 0; i < len(data); i++ {
100107

101108
log.Info("Save an issue ", data[i].Url)
102-
d.queries.CreateIssue(d.ctx,
109+
_, createErr := d.queries.CreateIssue(d.ctx,
103110
mapModelToDbParameter(data[i]))
111+
112+
if createErr != nil {
113+
log.Error("Error creating issue", createErr)
114+
}
104115
}
105116

106117
err = d.queries.UpdateTimeTaskData(d.ctx, sql.NullTime{Time: time.Now(), Valid: true})

internal/dbConnection.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package internal
33
import (
44
"database/sql"
55
"embed"
6-
_ "embed"
76
"fmt"
87
"net/http"
98

@@ -44,7 +43,10 @@ func NewConnection(migrationsFs embed.FS) DbConnection {
4443
}
4544

4645
func (dbConn *DbConnection) Close() {
47-
dbConn.Connection.Close()
46+
err := dbConn.Connection.Close()
47+
if err != nil {
48+
log.Error("error closing connection", err)
49+
}
4850
}
4951

5052
func ensureSchema(migrations embed.FS, db *sql.DB) error {

internal/mapperUtil.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ func mapGhQueryToHelpWantedIssue(query GhQuery) []HelpWantedIssue {
99
var helpLookingIssues []HelpWantedIssue
1010

1111
for _, repo := range query.Viewer.StarredRepositories.Nodes {
12-
if repo.Issues.Nodes == nil ||
13-
len(repo.Issues.Nodes) == 0 {
12+
if len(repo.Issues.Nodes) == 0 {
1413
continue
1514
}
1615
for _, issue := range repo.Issues.Nodes {

internal/matrixNotif.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import (
1111
)
1212

1313
type MatrixClient struct {
14-
client *mautrix.Client
15-
respLogin *mautrix.RespLogin
14+
client *mautrix.Client
1615
}
1716

1817
func CreateMatrixClient() *MatrixClient {

lint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# -v $(go env GOCACHE):/.cache/go-build -e GOCACHE=/.cache/go-build \
2+
# -v $(go env GOMODCACHE):/.cache/mod -e GOMODCACHE=/.cache/mod \
3+
# --user $(id -u):$(id -g) \
4+
docker run --rm -t -v $(pwd):/app -w /app \
5+
-v ./.cache/go-build:/.cache/go-build -e GOCACHE=/.cache/go-build \
6+
-v ./.cache/mod:/.cache/mod -e GOMODCACHE=/.cache/mod \
7+
-v ./.cache/golangci-lint:/.cache/golangci-lint -e GOLANGCI_LINT_CACHE=/.cache/golangci-lint \
8+
golangci/golangci-lint:v2.4.0 golangci-lint run

main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,9 @@ func main() {
4646
http.HandleFunc("/", webpageHandler.HandleWebPage)
4747

4848
log.Info("Server listening on port 1983")
49-
http.ListenAndServe(":1983", nil)
49+
err := http.ListenAndServe(":1983", nil)
50+
51+
if err != nil {
52+
log.Error("Server error", err)
53+
}
5054
}

0 commit comments

Comments
 (0)