Skip to content

Commit 75d98d0

Browse files
Merge pull request #3 from bloodsweatncode/addstats
Introduced Linting Introduced staticcheck
2 parents 6e4d2a1 + bd88bc7 commit 75d98d0

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ jobs:
2121
- name: Run Tests
2222
run: go test --cover ./...
2323

24+
- name: Install gosec
25+
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
26+
27+
- name: Run gosec
28+
run: gosec ./...
29+
2430
style:
2531
name: Style
2632
runs-on: ubuntu-latest
@@ -34,5 +40,11 @@ jobs:
3440
with:
3541
go-version: "1.23.0"
3642

43+
- name: Install staticcheck
44+
run: go install honnef.co/go/tools/cmd/staticcheck@latest
45+
3746
- name: Check Format
3847
run: test -z $(go fmt ./...)
48+
49+
- name: Linting
50+
run: staticcheck ./...

json.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
3030
return
3131
}
3232
w.WriteHeader(code)
33-
w.Write(dat)
33+
_, writeErr := w.Write(dat)
34+
if writeErr != nil {
35+
log.Printf("Error writing data: %s", err)
36+
}
3437
}

main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"log"
88
"net/http"
99
"os"
10+
"time"
1011

1112
"github.com/go-chi/chi"
1213
"github.com/go-chi/cors"
@@ -89,8 +90,10 @@ func main() {
8990

9091
router.Mount("/v1", v1Router)
9192
srv := &http.Server{
92-
Addr: ":" + port,
93-
Handler: router,
93+
Addr: ":" + port,
94+
ReadTimeout: 5 * time.Second,
95+
WriteTimeout: 10 * time.Second,
96+
Handler: router,
9497
}
9598

9699
log.Printf("Serving on port: %s\n", port)

0 commit comments

Comments
 (0)