Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GitHub actions, fix code according to golanci-lint latest version #108

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ 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
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
Loading