diff --git a/authentication.go b/authentication.go index bc654c4f..5ff05d96 100644 --- a/authentication.go +++ b/authentication.go @@ -3,9 +3,9 @@ package pgproto3 import ( "bytes" "encoding/binary" + "fmt" "github.com/jackc/pgio" - "github.com/pkg/errors" ) // Authentication message type constants. @@ -60,7 +60,7 @@ func (dst *Authentication) Decode(src []byte) error { case AuthTypeSASLContinue, AuthTypeSASLFinal: dst.SASLData = src[4:] default: - return errors.Errorf("unknown authentication type: %d", dst.Type) + return fmt.Errorf("unknown authentication type: %d", dst.Type) } return nil diff --git a/backend.go b/backend.go index be8f3bdb..176a25ba 100644 --- a/backend.go +++ b/backend.go @@ -4,8 +4,6 @@ import ( "encoding/binary" "fmt" "io" - - "github.com/pkg/errors" ) // Backend acts as a server for the PostgreSQL wire protocol version 3. @@ -124,7 +122,7 @@ func (b *Backend) Receive() (FrontendMessage, error) { case 'X': msg = &b.terminate default: - return nil, errors.Errorf("unknown message type: %c", b.msgType) + return nil, fmt.Errorf("unknown message type: %c", b.msgType) } msgBody, err := b.cr.Next(b.bodyLen) diff --git a/cancel_request.go b/cancel_request.go index ec1d8606..942e404b 100644 --- a/cancel_request.go +++ b/cancel_request.go @@ -3,9 +3,9 @@ package pgproto3 import ( "encoding/binary" "encoding/json" + "errors" "github.com/jackc/pgio" - "github.com/pkg/errors" ) const cancelRequestCode = 80877102 @@ -20,13 +20,13 @@ func (*CancelRequest) Frontend() {} func (dst *CancelRequest) Decode(src []byte) error { if len(src) != 12 { - return errors.Errorf("bad cancel request size") + return errors.New("bad cancel request size") } requestCode := binary.BigEndian.Uint32(src) if requestCode != cancelRequestCode { - return errors.Errorf("bad cancel request code") + return errors.New("bad cancel request code") } dst.ProcessID = binary.BigEndian.Uint32(src[4:]) diff --git a/frontend.go b/frontend.go index bcf796e1..f6ebaf43 100644 --- a/frontend.go +++ b/frontend.go @@ -2,9 +2,8 @@ package pgproto3 import ( "encoding/binary" + "fmt" "io" - - "github.com/pkg/errors" ) // Frontend acts as a client for the PostgreSQL wire protocol version 3. @@ -115,7 +114,7 @@ func (b *Frontend) Receive() (BackendMessage, error) { case 'Z': msg = &b.readyForQuery default: - return nil, errors.Errorf("unknown message type: %c", b.msgType) + return nil, fmt.Errorf("unknown message type: %c", b.msgType) } msgBody, err := b.cr.Next(b.bodyLen) diff --git a/frontend_test.go b/frontend_test.go index 2d5c8de7..1d6a07ae 100644 --- a/frontend_test.go +++ b/frontend_test.go @@ -1,10 +1,9 @@ package pgproto3_test import ( + "errors" "testing" - "github.com/pkg/errors" - "github.com/jackc/pgproto3/v2" ) diff --git a/go.mod b/go.mod index 800f6043..4821676a 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,6 @@ module github.com/jackc/pgproto3/v2 go 1.12 require ( - github.com/jackc/chunkreader v1.0.0 github.com/jackc/chunkreader/v2 v2.0.0 github.com/jackc/pgio v1.0.0 - github.com/pkg/errors v0.8.1 ) diff --git a/go.sum b/go.sum index 5dd456ad..36160794 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,4 @@ -github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= -github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= github.com/jackc/chunkreader/v2 v2.0.0 h1:DUwgMQuuPnS0rhMXenUtZpqZqrR/30NWY+qQvTpSvEs= github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/ssl_request.go b/ssl_request.go index 2f4b378a..96ce489e 100644 --- a/ssl_request.go +++ b/ssl_request.go @@ -3,9 +3,9 @@ package pgproto3 import ( "encoding/binary" "encoding/json" + "errors" "github.com/jackc/pgio" - "github.com/pkg/errors" ) const sslRequestNumber = 80877103 @@ -18,13 +18,13 @@ func (*SSLRequest) Frontend() {} func (dst *SSLRequest) Decode(src []byte) error { if len(src) < 4 { - return errors.Errorf("ssl request too short") + return errors.New("ssl request too short") } requestCode := binary.BigEndian.Uint32(src) if requestCode != sslRequestNumber { - return errors.Errorf("bad ssl request code") + return errors.New("bad ssl request code") } return nil diff --git a/startup_message.go b/startup_message.go index 5be42500..5f1cd24f 100644 --- a/startup_message.go +++ b/startup_message.go @@ -4,9 +4,10 @@ import ( "bytes" "encoding/binary" "encoding/json" + "errors" + "fmt" "github.com/jackc/pgio" - "github.com/pkg/errors" ) const ProtocolVersionNumber = 196608 // 3.0 @@ -23,14 +24,14 @@ func (*StartupMessage) Frontend() {} // type identifier and 4 byte message length. func (dst *StartupMessage) Decode(src []byte) error { if len(src) < 4 { - return errors.Errorf("startup message too short") + return errors.New("startup message too short") } dst.ProtocolVersion = binary.BigEndian.Uint32(src) rp := 4 if dst.ProtocolVersion != ProtocolVersionNumber { - return errors.Errorf("Bad startup message version number. Expected %d, got %d", ProtocolVersionNumber, dst.ProtocolVersion) + return fmt.Errorf("Bad startup message version number. Expected %d, got %d", ProtocolVersionNumber, dst.ProtocolVersion) } dst.Parameters = make(map[string]string) @@ -53,7 +54,7 @@ func (dst *StartupMessage) Decode(src []byte) error { if len(src[rp:]) == 1 { if src[rp] != 0 { - return errors.Errorf("Bad startup message last byte. Expected 0, got %d", src[rp]) + return fmt.Errorf("Bad startup message last byte. Expected 0, got %d", src[rp]) } break }