From e9d36b6baf557bae881919fa621d9d7803d56272 Mon Sep 17 00:00:00 2001 From: Dmitry Verkhoturov Date: Sat, 21 May 2022 08:58:12 +0200 Subject: [PATCH] get rid of errors package dependency --- cache.go | 4 +--- cache_test.go | 3 +-- go.mod | 5 +---- go.sum | 6 ++---- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/cache.go b/cache.go index 46fb7c5..5966a8b 100644 --- a/cache.go +++ b/cache.go @@ -17,8 +17,6 @@ import ( "fmt" "sync" "time" - - "github.com/pkg/errors" ) // Cache defines cache interface @@ -73,7 +71,7 @@ func NewCache(options ...Option) (Cache, error) { for _, opt := range options { if err := opt(&res); err != nil { - return nil, errors.Wrap(err, "failed to set cache option") + return nil, fmt.Errorf("failed to set cache option: %w", err) } } return &res, nil diff --git a/cache_test.go b/cache_test.go index 7f6354b..71ddce1 100644 --- a/cache_test.go +++ b/cache_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/pkg/errors" "github.com/stretchr/testify/assert" ) @@ -135,7 +134,7 @@ func TestCacheInvalidateAndEvict(t *testing.T) { func TestCacheBadOption(t *testing.T) { lc, err := NewCache(func(lc *cacheImpl) error { - return errors.New("mock err") + return fmt.Errorf("mock err") }) assert.EqualError(t, err, "failed to set cache option: mock err") assert.Nil(t, lc) diff --git a/go.mod b/go.mod index 5d5fdb0..ef16ec1 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,4 @@ module github.com/go-pkgz/expirable-cache go 1.14 -require ( - github.com/pkg/errors v0.9.1 - github.com/stretchr/testify v1.7.0 -) +require github.com/stretchr/testify v1.7.1 diff --git a/go.sum b/go.sum index 22c86e5..2dca7c9 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,10 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=