Skip to content

Commit

Permalink
update GitHub actions, fix code according to golancilint latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
paskal committed Feb 20, 2024
1 parent 8984270 commit 52e0204
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ jobs:

steps:
- name: set up go 1.19
uses: actions/setup-go@v1
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: "1.19"
id: go

- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: build and test
run: |
go test -timeout=60s -race
go build -race
- name: install golangci-lint
run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $GITHUB_WORKSPACE v1.45.2

- name: run golangci-lint
run: $GITHUB_WORKSPACE/golangci-lint run --out-format=github-actions
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
working-directory: backend/app
6 changes: 1 addition & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
linters:
enable:
- megacheck
- revive
- govet
- unconvert
- megacheck
- structcheck
- gas
- gocyclo
- dupl
- misspell
- unparam
- varcheck
- deadcode
- unused
- typecheck
- ineffassign
- varcheck
- stylecheck
- gochecknoinits
- exportloopref
Expand Down
12 changes: 6 additions & 6 deletions tollbooth_bug_report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ func Test_Issue48_RequestTerminatedEvenOnLowVolumeOnSameIP(t *testing.T) {
lmt.SetMethods([]string{"GET"})

limitReachedCounter := 0
lmt.SetOnLimitReached(func(w http.ResponseWriter, r *http.Request) { limitReachedCounter++ })
lmt.SetOnLimitReached(func(http.ResponseWriter, *http.Request) { limitReachedCounter++ })

handler := LimitHandler(lmt, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
handler := LimitHandler(lmt, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.Write([]byte(`hello world`))
}))

Expand Down Expand Up @@ -74,7 +74,7 @@ func Test_Issue66_CustomRateLimitByHeaderValues(t *testing.T) {
customerID1 := "1234"
customerID2 := "5678"

h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
h := http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})

h, allocationLimiter := issue66RateLimiter(h, []string{customerID1, customerID2})
testServer := httptest.NewServer(h)
Expand Down Expand Up @@ -145,7 +145,7 @@ func Test_Issue91_BrokenSetMethod_DontBlockGet(t *testing.T) {

// -------------------------------------------------------------------

handler := LimitHandler(lmt, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
handler := LimitHandler(lmt, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.Write([]byte(`hello world`))
}))

Expand Down Expand Up @@ -174,7 +174,7 @@ func Test_Issue91_BrokenSetMethod_BlockPost(t *testing.T) {
lmt.SetMethods([]string{"POST"})

limitReachedCounter := 0
lmt.SetOnLimitReached(func(w http.ResponseWriter, r *http.Request) {
lmt.SetOnLimitReached(func(http.ResponseWriter, *http.Request) {
limitReachedCounter++
})

Expand All @@ -185,7 +185,7 @@ func Test_Issue91_BrokenSetMethod_BlockPost(t *testing.T) {

// -------------------------------------------------------------------

handler := LimitHandler(lmt, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
handler := LimitHandler(lmt, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.Write([]byte(`hello world`))
}))

Expand Down
8 changes: 4 additions & 4 deletions tollbooth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ func TestLimitHandler(t *testing.T) {
lmt.SetMethods([]string{"POST"})

counter := 0
lmt.SetOnLimitReached(func(w http.ResponseWriter, r *http.Request) { counter++ })
lmt.SetOnLimitReached(func(http.ResponseWriter, *http.Request) { counter++ })

handler := LimitHandler(lmt, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
handler := LimitHandler(lmt, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.Write([]byte(`hello world`))
}))

Expand Down Expand Up @@ -411,14 +411,14 @@ func TestOverrideForResponseWriter(t *testing.T) {
lmt.SetOverrideDefaultResponseWriter(true)

counter := 0
lmt.SetOnLimitReached(func(w http.ResponseWriter, r *http.Request) {
lmt.SetOnLimitReached(func(w http.ResponseWriter, _ *http.Request) {
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusNotAcceptable)
w.Write([]byte("rejecting the large amount of requests"))
counter++
})

handler := LimitHandler(lmt, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
handler := LimitHandler(lmt, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.Write([]byte(`hello world`))
}))

Expand Down

0 comments on commit 52e0204

Please sign in to comment.