Skip to content

Commit a0f5513

Browse files
adapted error
1 parent b919347 commit a0f5513

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func (c *cache) IncrementInt64(k string, n int64) (int64, error) {
349349
v, found := c.items[k]
350350
if !found || v.Expired() {
351351
c.mu.Unlock()
352-
return 0, fmt.Errorf("Item %s not found", k)
352+
return 0, ErrNotFound
353353
}
354354
rv, ok := v.Object.(int64)
355355
if !ok {

errors.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package cache
2+
3+
import "errors"
4+
5+
var ErrNotFound error = errors.New("item not found")

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module go-cache/v2
2+
3+
go 1.22.0

0 commit comments

Comments
 (0)