diff --git a/blackmagic.go b/blackmagic.go index c97eefd..8d1d468 100644 --- a/blackmagic.go +++ b/blackmagic.go @@ -1,9 +1,8 @@ package blackmagic import ( + "fmt" "reflect" - - "github.com/pkg/errors" ) // AssignIfCompatible is a convenience function to safely @@ -23,12 +22,12 @@ func AssignIfCompatible(dst, src interface{}) error { case reflect.Slice: isSlice = true default: - return errors.Errorf("argument t to AssignIfCompatible must be a pointer or a slice: %T", src) + return fmt.Errorf("argument t to AssignIfCompatible must be a pointer or a slice: %T", src) } rv := reflect.ValueOf(dst) if rv.Kind() != reflect.Ptr { - return errors.Errorf(`argument to AssignIfCompatible() must be a pointer: %T`, dst) + return fmt.Errorf(`argument to AssignIfCompatible() must be a pointer: %T`, dst) } actualDst := rv.Elem() @@ -43,11 +42,11 @@ func AssignIfCompatible(dst, src interface{}) error { } } if !result.Type().AssignableTo(actualDst.Type()) { - return errors.Errorf(`argument to AssignIfCompatible() must be compatible with %T (was %T)`, orv.Interface(), dst) + return fmt.Errorf(`argument to AssignIfCompatible() must be compatible with %T (was %T)`, orv.Interface(), dst) } if !actualDst.CanSet() { - return errors.Errorf(`argument to AssignIfCompatible() must be settable`) + return fmt.Errorf(`argument to AssignIfCompatible() must be settable`) } actualDst.Set(result) diff --git a/blackmagic_test.go b/blackmagic_test.go index 53ac302..413f523 100644 --- a/blackmagic_test.go +++ b/blackmagic_test.go @@ -37,6 +37,15 @@ func TestAssignment(t *testing.T) { return &v }, }, + { + Name: `lestrrat-go/jwx#389`, + Error: true, + Value: + Destination: func() interface{} { + var s struct{} + return &s + }, + }, } for _, tc := range testcases { diff --git a/go.mod b/go.mod index 8248ac3..8837714 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,4 @@ module github.com/lestrrat-go/blackmagic go 1.16 -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..307d5b4 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,13 @@ 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 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= 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=