Skip to content

Commit e89e167

Browse files
authored
chore: Add golangci (#4)
1 parent 2cd427d commit e89e167

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

.github/workflows/go.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ jobs:
3131
with:
3232
ref: ${{ github.ref }}
3333

34+
- name: golangci-lint
35+
uses: golangci/golangci-lint-action@v2
36+
3437
- name: Run Tests
3538
run: |
3639
go test -v -covermode=atomic -coverprofile=coverage.out

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Timeout wraps a handler and aborts the process of the handler if the timeout is
1414
package main
1515

1616
import (
17+
"log"
1718
"net/http"
1819
"time"
1920

@@ -35,8 +36,11 @@ func main() {
3536
))
3637

3738
// Listen and Server in 0.0.0.0:8080
38-
r.Run(":8080")
39+
if err := r.Run(":8080"); err != nil {
40+
log.Fatal(err)
41+
}
3942
}
43+
4044
```
4145

4246
### custom error response

example/main.go

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

33
import (
4+
"log"
45
"net/http"
56
"time"
67

@@ -22,5 +23,7 @@ func main() {
2223
))
2324

2425
// Listen and Server in 0.0.0.0:8080
25-
r.Run(":8080")
26+
if err := r.Run(":8080"); err != nil {
27+
log.Fatal(err)
28+
}
2629
}

timeout.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ type Timeout struct {
4242
response gin.HandlerFunc
4343
}
4444

45-
var (
46-
buffpool *BufferPool
47-
)
45+
var buffpool *BufferPool
4846

4947
// New wraps a handler and aborts the process of the handler if the timeout is reached
5048
func New(opts ...Option) gin.HandlerFunc {
@@ -104,7 +102,9 @@ func New(opts ...Option) gin.HandlerFunc {
104102
dst[k] = vv
105103
}
106104
tw.ResponseWriter.WriteHeader(tw.code)
107-
tw.ResponseWriter.Write(buffer.Bytes())
105+
if _, err := tw.ResponseWriter.Write(buffer.Bytes()); err != nil {
106+
panic(err)
107+
}
108108
tw.FreeBuffer()
109109
buffpool.Put(buffer)
110110

0 commit comments

Comments
 (0)