diff --git a/README.md b/README.md index 2613d63..01ee294 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This is the [Go](http://golang.org) implementation of **Frisbee**, a bring-your- protocol messaging framework designed for performance and stability. -**This library requires Go1.18 or later.** +**This library requires Go1.20 or later.** ## Important note about releases and stability diff --git a/async.go b/async.go index bae31b1..170edef 100644 --- a/async.go +++ b/async.go @@ -21,16 +21,17 @@ import ( "context" "crypto/tls" "encoding/binary" + "errors" + "net" + "sync" + "time" + "github.com/loopholelabs/common/pkg/queue" "github.com/loopholelabs/frisbee-go/internal/dialer" "github.com/loopholelabs/frisbee-go/pkg/metadata" "github.com/loopholelabs/frisbee-go/pkg/packet" - "github.com/pkg/errors" "github.com/rs/zerolog" "go.uber.org/atomic" - "net" - "sync" - "time" ) // Async is the underlying asynchronous frisbee connection which has extremely efficient read and write logic and diff --git a/conn.go b/conn.go index c9b878c..2fe4a9f 100644 --- a/conn.go +++ b/conn.go @@ -19,12 +19,13 @@ package frisbee import ( "context" "crypto/tls" - "github.com/loopholelabs/frisbee-go/pkg/packet" - "github.com/pkg/errors" - "github.com/rs/zerolog" + "errors" "io" "net" "time" + + "github.com/loopholelabs/frisbee-go/pkg/packet" + "github.com/rs/zerolog" ) // DefaultBufferSize is the size of the default buffer diff --git a/frisbee.go b/frisbee.go index 27de45b..b844ce7 100644 --- a/frisbee.go +++ b/frisbee.go @@ -18,11 +18,12 @@ package frisbee import ( "context" + "errors" + "time" + "github.com/loopholelabs/frisbee-go/pkg/metadata" "github.com/loopholelabs/frisbee-go/pkg/packet" "github.com/loopholelabs/polyglot" - "github.com/pkg/errors" - "time" ) // These are various frisbee errors that can be returned by the client or server: diff --git a/go.mod b/go.mod index 4aec280..b978bdd 100644 --- a/go.mod +++ b/go.mod @@ -1,24 +1,23 @@ module github.com/loopholelabs/frisbee-go -go 1.18 +go 1.20 require ( github.com/loopholelabs/common v0.4.9 - github.com/loopholelabs/polyglot v1.1.2 + github.com/loopholelabs/polyglot v1.1.4 github.com/loopholelabs/testing v0.2.3 - github.com/pkg/errors v0.9.1 - github.com/rs/zerolog v1.30.0 + github.com/rs/zerolog v1.31.0 github.com/stretchr/testify v1.8.4 go.uber.org/atomic v1.11.0 - go.uber.org/goleak v1.2.1 + go.uber.org/goleak v1.3.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/kr/text v0.2.0 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect + golang.org/x/sys v0.15.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index a552fd6..f51ac76 100644 --- a/go.sum +++ b/go.sum @@ -8,31 +8,33 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/loopholelabs/common v0.4.9 h1:9MPUYlZZ/qx3Kt8LXgXxcSXthrM91od8026c4DlGpAU= github.com/loopholelabs/common v0.4.9/go.mod h1:Wop5srN1wYT+mdQ9gZ+kn2I9qKAyVd0FB48pThwIa9M= -github.com/loopholelabs/polyglot v1.1.2 h1:9JE1m/IL8rgWIlykvebz98i4tjOGNOpgGIB3CqbfvrE= -github.com/loopholelabs/polyglot v1.1.2/go.mod h1:EA88BEkIluKHAWxhyOV88xXz68YkRdo9IzZ+1dj+7Ao= +github.com/loopholelabs/polyglot v1.1.4 h1:+yCGD3MQnmmX5ln+9mCbSCUgH7GQH0RxKJn/54hAaQU= +github.com/loopholelabs/polyglot v1.1.4/go.mod h1:EA88BEkIluKHAWxhyOV88xXz68YkRdo9IzZ+1dj+7Ao= github.com/loopholelabs/testing v0.2.3 h1:4nVuK5ctaE6ua5Z0dYk2l7xTFmcpCYLUeGjRBp8keOA= github.com/loopholelabs/testing v0.2.3/go.mod h1:gqtGY91soYD1fQoKQt/6kP14OYpS7gcbcIgq5mc9m8Q= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 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/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= -github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= +github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= +github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= -go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/pkg/metadata/metadata.go b/pkg/metadata/metadata.go index e1455b0..2c755d0 100644 --- a/pkg/metadata/metadata.go +++ b/pkg/metadata/metadata.go @@ -18,15 +18,14 @@ package metadata import ( "encoding/binary" + "errors" "unsafe" - - "github.com/pkg/errors" ) var ( - Encoding = errors.New("error while encoding metadata") - Decoding = errors.New("error while decoding metadata") - InvalidBufferLength = errors.New("invalid buffer length") + EncodingErr = errors.New("error while encoding metadata") + DecodingErr = errors.New("error while decoding metadata") + InvalidBufferLengthErr = errors.New("invalid buffer length") ) const ( @@ -59,7 +58,7 @@ type Metadata struct { func (fm *Metadata) Encode() (b *Buffer, err error) { defer func() { if recoveredErr := recover(); recoveredErr != nil { - err = errors.Wrap(recoveredErr.(error), Encoding.Error()) + err = errors.Join(recoveredErr.(error), EncodingErr) } }() @@ -75,7 +74,7 @@ func (fm *Metadata) Encode() (b *Buffer, err error) { func (fm *Metadata) Decode(buf *Buffer) (err error) { defer func() { if recoveredErr := recover(); recoveredErr != nil { - err = errors.Wrap(recoveredErr.(error), Decoding.Error()) + err = errors.Join(recoveredErr.(error), DecodingErr) } }() @@ -98,7 +97,7 @@ func Encode(id, operation uint16, contentLength uint32) (*Buffer, error) { func Decode(buf []byte) (*Metadata, error) { if len(buf) < Size { - return nil, InvalidBufferLength + return nil, InvalidBufferLengthErr } m := new(Metadata) diff --git a/pkg/metadata/metadata_test.go b/pkg/metadata/metadata_test.go index 786bea2..11f3699 100644 --- a/pkg/metadata/metadata_test.go +++ b/pkg/metadata/metadata_test.go @@ -18,9 +18,10 @@ package metadata import ( "encoding/binary" + "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func TestMessageEncodeDecode(t *testing.T) { @@ -72,7 +73,7 @@ func TestEncodeDecode(t *testing.T) { invalidMessage, err := Decode(emptyEncodedBytes[1:]) require.Error(t, err) - assert.ErrorIs(t, InvalidBufferLength, err) + assert.ErrorIs(t, InvalidBufferLengthErr, err) assert.Nil(t, invalidMessage) } diff --git a/server.go b/server.go index 376883d..8676be7 100644 --- a/server.go +++ b/server.go @@ -19,12 +19,12 @@ package frisbee import ( "context" "crypto/tls" + "errors" "net" "sync" "time" "github.com/loopholelabs/frisbee-go/pkg/packet" - "github.com/pkg/errors" "github.com/rs/zerolog" "go.uber.org/atomic" ) diff --git a/sync.go b/sync.go index e2b0746..9e58809 100644 --- a/sync.go +++ b/sync.go @@ -20,6 +20,7 @@ import ( "context" "crypto/tls" "encoding/binary" + "errors" "io" "net" "sync" @@ -28,7 +29,6 @@ import ( "github.com/loopholelabs/frisbee-go/internal/dialer" "github.com/loopholelabs/frisbee-go/pkg/metadata" "github.com/loopholelabs/frisbee-go/pkg/packet" - "github.com/pkg/errors" "github.com/rs/zerolog" "go.uber.org/atomic" )