Skip to content

Commit bf261e6

Browse files
authored
Merge branch 'main' into dependabot/github_actions/toolmantim/release-drafter-6.1.0
2 parents e5c4aba + 760fdf5 commit bf261e6

9 files changed

Lines changed: 41 additions & 22 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
id: go
2222

2323
- name: Check out code into the Go module directory
24-
uses: actions/checkout@v4
24+
uses: actions/checkout@v6
2525

2626
- name: Lint code
27-
uses: golangci/golangci-lint-action@v6
27+
uses: golangci/golangci-lint-action@e7fa5ac41e1cf5b7d48e45e42232ce7ada589601
2828
with:
2929
only-new-issues: true
3030

.golangci.yaml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1+
version: "2"
12
linters:
23
disable:
34
- errcheck
4-
linters-settings:
5-
staticcheck:
6-
checks:
7-
- all
8-
- '-SA1019'
5+
settings:
6+
staticcheck:
7+
checks:
8+
- -SA1019
9+
- all
10+
exclusions:
11+
generated: lax
12+
presets:
13+
- comments
14+
- common-false-positives
15+
- legacy
16+
- std-error-handling
17+
paths:
18+
- third_party$
19+
- builtin$
20+
- examples$
21+
formatters:
22+
exclusions:
23+
generated: lax
24+
paths:
25+
- third_party$
26+
- builtin$
27+
- examples$

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ Requires Go 1.12 or newer.
1212

1313
```go
1414
import (
15-
"fmt"
1615
"context"
16+
"fmt"
17+
"time"
1718
"github.com/allegro/bigcache/v3"
1819
)
1920

@@ -32,7 +33,10 @@ allocation can be avoided in that way.
3233

3334
```go
3435
import (
36+
"context"
37+
"fmt"
3538
"log"
39+
"time"
3640

3741
"github.com/allegro/bigcache/v3"
3842
)

assert_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func noError(t *testing.T, e error) {
2424
if e != nil {
2525
_, file, line, _ := runtime.Caller(1)
2626
file = path.Base(file)
27-
t.Errorf(fmt.Sprintf("\n%s:%d: Error is not nil: \n"+
28-
"actual : %T(%#v)\n", file, line, e, e))
27+
t.Errorf("\n%s:%d: Error is not nil: \n"+
28+
"actual : %T(%#v)\n", file, line, e, e)
2929
}
3030
}
3131

bigcache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func NewBigCache(config Config) (*BigCache, error) {
5757

5858
func newBigCache(ctx context.Context, config Config, clock clock) (*BigCache, error) {
5959
if !isPowerOfTwo(config.Shards) {
60-
return nil, errors.New("Shards number must be power of two")
60+
return nil, errors.New("Shards number must be power of two") //nolint:staticcheck // keep for backward compatibility
6161
}
6262
if config.MaxEntrySize < 0 {
6363
return nil, errors.New("MaxEntrySize must be >= 0")

bytes_appengine.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build appengine
2-
// +build appengine
32

43
package bigcache
54

entry_not_found_error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import "errors"
44

55
var (
66
// ErrEntryNotFound is an error type struct which is returned when entry was not found for provided key
7-
ErrEntryNotFound = errors.New("Entry not found")
7+
ErrEntryNotFound = errors.New("Entry not found") //nolint:staticcheck // keep for backward compatibility
88
)

iterator_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,8 @@ func TestParallelSetAndIteration(t *testing.T) {
219219

220220
isTimeout := false
221221

222-
for {
223-
if isTimeout {
224-
break
225-
}
222+
for !isTimeout {
223+
226224
select {
227225
case <-ctx.Done():
228226
isTimeout = true
@@ -244,10 +242,8 @@ func TestParallelSetAndIteration(t *testing.T) {
244242

245243
isTimeout := false
246244

247-
for {
248-
if isTimeout {
249-
break
250-
}
245+
for !isTimeout {
246+
251247
select {
252248
case <-ctx.Done():
253249
isTimeout = true

queue/bytes_queue.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ var (
1717
errEmptyQueue = &queueError{"Empty queue"}
1818
errInvalidIndex = &queueError{"Index must be greater than zero. Invalid index."}
1919
errIndexOutOfBounds = &queueError{"Index out of range"}
20+
errFullQueue = &queueError{"Full queue. Maximum size limit reached."}
2021
)
2122

2223
// BytesQueue is a non-thread safe queue type of fifo based on bytes array.
@@ -92,7 +93,7 @@ func (q *BytesQueue) Push(data []byte) (int, error) {
9293
if q.canInsertBeforeHead(neededSize) {
9394
q.tail = leftMarginIndex
9495
} else if q.capacity+neededSize >= q.maxCapacity && q.maxCapacity > 0 {
95-
return -1, &queueError{"Full queue. Maximum size limit reached."}
96+
return -1, errFullQueue
9697
} else {
9798
q.allocateAdditionalMemory(neededSize)
9899
}

0 commit comments

Comments
 (0)