Skip to content

Commit 20d0c5c

Browse files
committed
feat(deps): bump golangci-lint CI version
1 parent 5f2328c commit 20d0c5c

5 files changed

Lines changed: 39 additions & 32 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ jobs:
1717
# The Windows build currently fail because of https://github.com/golang/go/issues/40795, and because xcaddy isn't compatible with the known workaround
1818
#os: [ ubuntu-latest, macos-latest, windows-latest ]
1919
os: [ ubuntu-latest, macos-latest ]
20-
go: [ '1.21' ]
20+
go: [ '1.24' ]
2121

2222
runs-on: ${{ matrix.os }}
2323

2424
steps:
2525
- name: Install Go
26-
uses: actions/setup-go@v4
26+
uses: actions/setup-go@v5
2727
with:
2828
go-version: ${{ matrix.go }}
2929

3030
- name: Checkout code
31-
uses: actions/checkout@v3
31+
uses: actions/checkout@v4
3232

3333
- name: Print Go version and environment
3434
id: vars
@@ -44,7 +44,7 @@ jobs:
4444
echo "::set-output name=go_cache::$(go env GOCACHE)"
4545
4646
- name: Cache the build cache
47-
uses: actions/cache@v2
47+
uses: actions/cache@v4
4848
with:
4949
path: ${{ steps.vars.outputs.go_cache }}
5050
key: ${{ runner.os }}-${{ matrix.go }}-go-ci-${{ hashFiles('**/go.sum') }}
@@ -71,11 +71,11 @@ jobs:
7171
runs-on: ubuntu-latest
7272

7373
steps:
74-
- uses: actions/checkout@v3
75-
- uses: actions/setup-go@v4
74+
- uses: actions/checkout@v4
75+
- uses: actions/setup-go@v5
7676
with:
77-
go-version: '1.21'
77+
go-version: '1.24'
7878
- name: golangci-lint
79-
uses: golangci/golangci-lint-action@v3
79+
uses: golangci/golangci-lint-action@v8
8080
with:
8181
args: --timeout 5m

cleaner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ func newStorageProvider() *storage_providers {
2121
}
2222

2323
func (s *storage_providers) Add(key interface{}) {
24-
s.RWMutex.Lock()
25-
defer s.RWMutex.Unlock()
24+
s.Lock()
25+
defer s.Unlock()
2626

2727
s.list[key] = true
2828
}

configuration.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,12 @@ func parseRedisConfiguration(c map[string]interface{}) map[string]interface{} {
321321
case "SendToReplicas", "ShuffleInit", "ClientNoTouch", "DisableRetry", "DisableCache", "AlwaysPipelining", "AlwaysRESP2", "ForceSingleClient", "ReplicaOnly", "ClientNoEvict", "ContextTimeoutEnabled", "PoolFIFO", "ReadOnly", "RouteByLatency", "RouteRandomly", "DisableIndentity":
322322
c[k] = true
323323
case "SelectDB", "CacheSizeEachConn", "RingScaleEachConn", "ReadBufferEachConn", "WriteBufferEachConn", "BlockingPoolSize", "PipelineMultiplex", "DB", "Protocol", "MaxRetries", "PoolSize", "MinIdleConns", "MaxIdleConns", "MaxActiveConns", "MaxRedirects":
324-
if v == false {
324+
switch v {
325+
case false:
325326
c[k] = 0
326-
} else if v == true {
327+
case true:
327328
c[k] = 1
328-
} else {
329+
default:
329330
c[k], _ = strconv.Atoi(v.(string))
330331
}
331332
case "ConnWriteTimeout", "MaxFlushDelay", "MinRetryBackoff", "MaxRetryBackoff", "DialTimeout", "ReadTimeout", "WriteTimeout", "PoolTimeout", "ConnMaxIdleTime", "ConnMaxLifetime":
@@ -362,19 +363,21 @@ func parseSimpleFSConfiguration(c map[string]interface{}) map[string]interface{}
362363
case "path":
363364
c[k] = v
364365
case "size":
365-
if v == false {
366+
switch v {
367+
case false:
366368
c[k] = 0
367-
} else if v == true {
369+
case true:
368370
c[k] = 1
369-
} else {
371+
default:
370372
c[k], _ = strconv.Atoi(v.(string))
371373
}
372374
case "directory_size":
373-
if v == false {
375+
switch v {
376+
case false:
374377
c[k] = 0
375-
} else if v == true {
378+
case true:
376379
c[k] = 1
377-
} else {
380+
default:
378381
c[k], _ = strconv.Atoi(v.(string))
379382
}
380383
}

httpcache.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,16 @@ func (s *SouinCaddyMiddleware) FromApp(app *SouinApp) error {
136136
}
137137
}
138138

139-
if app.DefaultCache.GetTTL() == 0 {
139+
if app.GetTTL() == 0 {
140140
if s.Configuration.DefaultCache.GetTTL() == 0 {
141-
app.DefaultCache.TTL = configurationtypes.Duration{Duration: 120 * time.Second}
141+
app.TTL = configurationtypes.Duration{Duration: 120 * time.Second}
142142
}
143143
}
144144

145145
if s.Configuration.GetDefaultCache() == nil {
146146
s.Configuration.DefaultCache = DefaultCache{
147-
AllowedHTTPVerbs: app.DefaultCache.AllowedHTTPVerbs,
148-
AllowedAdditionalStatusCodes: app.DefaultCache.AllowedAdditionalStatusCodes,
147+
AllowedHTTPVerbs: app.AllowedHTTPVerbs,
148+
AllowedAdditionalStatusCodes: app.AllowedAdditionalStatusCodes,
149149
Headers: app.Headers,
150150
Key: app.Key,
151151
TTL: app.TTL,
@@ -156,7 +156,7 @@ func (s *SouinCaddyMiddleware) FromApp(app *SouinApp) error {
156156
}
157157
return nil
158158
}
159-
if s.Configuration.CacheKeys == nil || len(s.Configuration.CacheKeys) == 0 {
159+
if len(s.Configuration.CacheKeys) == 0 {
160160
s.Configuration.CacheKeys = configurationtypes.CacheKeys{}
161161
}
162162
if s.CacheKeys == nil {
@@ -175,7 +175,7 @@ func (s *SouinCaddyMiddleware) FromApp(app *SouinApp) error {
175175
appDc := app.DefaultCache
176176
s.Configuration.DefaultCache.AllowedHTTPVerbs = append(s.Configuration.DefaultCache.AllowedHTTPVerbs, appDc.AllowedHTTPVerbs...)
177177
s.Configuration.DefaultCache.AllowedAdditionalStatusCodes = append(s.Configuration.DefaultCache.AllowedAdditionalStatusCodes, appDc.AllowedAdditionalStatusCodes...)
178-
s.Configuration.DefaultCache.CDN = app.DefaultCache.CDN
178+
s.Configuration.DefaultCache.CDN = app.CDN
179179
if dc.Headers == nil {
180180
s.Configuration.DefaultCache.Headers = appDc.Headers
181181
}
@@ -278,9 +278,9 @@ func (s *SouinCaddyMiddleware) Provision(ctx caddy.Context) error {
278278
}
279279

280280
if app.SurrogateStorage == (surrogates_providers.SurrogateInterface)(nil) {
281-
app.SurrogateStorage = s.SouinBaseHandler.SurrogateKeyStorer
281+
app.SurrogateStorage = s.SurrogateKeyStorer
282282
} else {
283-
s.SouinBaseHandler.SurrogateKeyStorer = app.SurrogateStorage
283+
s.SurrogateKeyStorer = app.SurrogateStorage
284284
}
285285

286286
return nil

httpcache_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,8 @@ func TestAuthenticatedRoute(t *testing.T) {
480480
t.Errorf("unexpected Cache-Status header %v", respAuthBypassAlice1.Header.Get("Cache-Status"))
481481
}
482482
respAuthBypassAlice2, _ := tester.AssertResponse(getRequestFor("/auth-bypass", "Alice"), 200, "Hello, auth bypass Bearer Alice!")
483-
if respAuthBypassAlice2.Header.Get("Cache-Status") != "Souin; hit; ttl=4; key=GET-http-localhost:9080-/auth-bypass-Bearer Alice-text/plain; detail=DEFAULT" {
483+
if respAuthBypassAlice2.Header.Get("Cache-Status") != "Souin; hit; ttl=4; key=GET-http-localhost:9080-/auth-bypass-Bearer Alice-text/plain; detail=DEFAULT" &&
484+
respAuthBypassAlice2.Header.Get("Cache-Status") != "Souin; hit; ttl=3; key=GET-http-localhost:9080-/auth-bypass-Bearer Alice-text/plain; detail=DEFAULT" {
484485
t.Errorf("unexpected Cache-Status header %v", respAuthBypassAlice2.Header.Get("Cache-Status"))
485486
}
486487

@@ -489,7 +490,8 @@ func TestAuthenticatedRoute(t *testing.T) {
489490
t.Errorf("unexpected Cache-Status header %v", respAuthBypassBob1.Header.Get("Cache-Status"))
490491
}
491492
respAuthBypassBob2, _ := tester.AssertResponse(getRequestFor("/auth-bypass", "Bob"), 200, "Hello, auth bypass Bearer Bob!")
492-
if respAuthBypassBob2.Header.Get("Cache-Status") != "Souin; hit; ttl=4; key=GET-http-localhost:9080-/auth-bypass-Bearer Bob-text/plain; detail=DEFAULT" {
493+
if respAuthBypassBob2.Header.Get("Cache-Status") != "Souin; hit; ttl=4; key=GET-http-localhost:9080-/auth-bypass-Bearer Bob-text/plain; detail=DEFAULT" &&
494+
respAuthBypassBob2.Header.Get("Cache-Status") != "Souin; hit; ttl=3; key=GET-http-localhost:9080-/auth-bypass-Bearer Bob-text/plain; detail=DEFAULT" {
493495
t.Errorf("unexpected Cache-Status header %v", respAuthBypassBob2.Header.Get("Cache-Status"))
494496
}
495497

@@ -498,7 +500,8 @@ func TestAuthenticatedRoute(t *testing.T) {
498500
t.Errorf("unexpected Cache-Status header %v", respAuthVaryBypassAlice1.Header.Get("Cache-Status"))
499501
}
500502
respAuthVaryBypassAlice2, _ := tester.AssertResponse(getRequestFor("/auth-bypass-vary", "Alice"), 200, "Hello, auth vary bypass Bearer Alice!")
501-
if respAuthVaryBypassAlice2.Header.Get("Cache-Status") != "Souin; hit; ttl=4; key=GET-http-localhost:9080-/auth-bypass-vary-Bearer Alice-text/plain; detail=DEFAULT" {
503+
if respAuthVaryBypassAlice2.Header.Get("Cache-Status") != "Souin; hit; ttl=4; key=GET-http-localhost:9080-/auth-bypass-vary-Bearer Alice-text/plain; detail=DEFAULT" &&
504+
respAuthVaryBypassAlice2.Header.Get("Cache-Status") != "Souin; hit; ttl=3; key=GET-http-localhost:9080-/auth-bypass-vary-Bearer Alice-text/plain; detail=DEFAULT" {
502505
t.Errorf("unexpected Cache-Status header %v", respAuthVaryBypassAlice2.Header.Get("Cache-Status"))
503506
}
504507
}
@@ -820,7 +823,7 @@ func (t *testVaryHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
820823
w.Header().Set("Vary", variedHeader)
821824
w.Header().Set(variedHeader, r.Header.Get(variedHeader))
822825
w.WriteHeader(http.StatusOK)
823-
_, _ = w.Write([]byte(fmt.Sprintf("Hello, vary %s!", r.Header.Get(variedHeader))))
826+
_, _ = fmt.Fprintf(w, "Hello, vary %s!", r.Header.Get(variedHeader))
824827
}
825828

826829
func TestVaryHandler(t *testing.T) {
@@ -1178,7 +1181,8 @@ func TestExpires(t *testing.T) {
11781181
t.Errorf("unexpected Age header %v", resp1.Header.Get("Age"))
11791182
}
11801183

1181-
if resp1.Header.Get("Cache-Status") != fmt.Sprintf("Souin; hit; ttl=%d; key=GET-http-localhost:9080-%s; detail=DEFAULT", expectedDuration, path) {
1184+
if resp1.Header.Get("Cache-Status") != fmt.Sprintf("Souin; hit; ttl=%d; key=GET-http-localhost:9080-%s; detail=DEFAULT", expectedDuration, path) &&
1185+
resp1.Header.Get("Cache-Status") != fmt.Sprintf("Souin; hit; ttl=%d; key=GET-http-localhost:9080-%s; detail=DEFAULT", expectedDuration-1, path) {
11821186
t.Errorf(
11831187
"unexpected second Cache-Status header %v, expected %s",
11841188
resp1.Header.Get("Cache-Status"),

0 commit comments

Comments
 (0)