Remove pkg/errors package
This commit is contained in:
+2
-2
@@ -3,9 +3,9 @@ package pgproto3
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/jackc/pgio"
|
"github.com/jackc/pgio"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Authentication message type constants.
|
// Authentication message type constants.
|
||||||
@@ -60,7 +60,7 @@ func (dst *Authentication) Decode(src []byte) error {
|
|||||||
case AuthTypeSASLContinue, AuthTypeSASLFinal:
|
case AuthTypeSASLContinue, AuthTypeSASLFinal:
|
||||||
dst.SASLData = src[4:]
|
dst.SASLData = src[4:]
|
||||||
default:
|
default:
|
||||||
return errors.Errorf("unknown authentication type: %d", dst.Type)
|
return fmt.Errorf("unknown authentication type: %d", dst.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
+1
-3
@@ -4,8 +4,6 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Backend acts as a server for the PostgreSQL wire protocol version 3.
|
// Backend acts as a server for the PostgreSQL wire protocol version 3.
|
||||||
@@ -124,7 +122,7 @@ func (b *Backend) Receive() (FrontendMessage, error) {
|
|||||||
case 'X':
|
case 'X':
|
||||||
msg = &b.terminate
|
msg = &b.terminate
|
||||||
default:
|
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)
|
msgBody, err := b.cr.Next(b.bodyLen)
|
||||||
|
|||||||
+3
-3
@@ -3,9 +3,9 @@ package pgproto3
|
|||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/jackc/pgio"
|
"github.com/jackc/pgio"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const cancelRequestCode = 80877102
|
const cancelRequestCode = 80877102
|
||||||
@@ -20,13 +20,13 @@ func (*CancelRequest) Frontend() {}
|
|||||||
|
|
||||||
func (dst *CancelRequest) Decode(src []byte) error {
|
func (dst *CancelRequest) Decode(src []byte) error {
|
||||||
if len(src) != 12 {
|
if len(src) != 12 {
|
||||||
return errors.Errorf("bad cancel request size")
|
return errors.New("bad cancel request size")
|
||||||
}
|
}
|
||||||
|
|
||||||
requestCode := binary.BigEndian.Uint32(src)
|
requestCode := binary.BigEndian.Uint32(src)
|
||||||
|
|
||||||
if requestCode != cancelRequestCode {
|
if requestCode != cancelRequestCode {
|
||||||
return errors.Errorf("bad cancel request code")
|
return errors.New("bad cancel request code")
|
||||||
}
|
}
|
||||||
|
|
||||||
dst.ProcessID = binary.BigEndian.Uint32(src[4:])
|
dst.ProcessID = binary.BigEndian.Uint32(src[4:])
|
||||||
|
|||||||
+2
-3
@@ -2,9 +2,8 @@ package pgproto3
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Frontend acts as a client for the PostgreSQL wire protocol version 3.
|
// Frontend acts as a client for the PostgreSQL wire protocol version 3.
|
||||||
@@ -115,7 +114,7 @@ func (b *Frontend) Receive() (BackendMessage, error) {
|
|||||||
case 'Z':
|
case 'Z':
|
||||||
msg = &b.readyForQuery
|
msg = &b.readyForQuery
|
||||||
default:
|
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)
|
msgBody, err := b.cr.Next(b.bodyLen)
|
||||||
|
|||||||
+1
-2
@@ -1,10 +1,9 @@
|
|||||||
package pgproto3_test
|
package pgproto3_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/jackc/pgproto3/v2"
|
"github.com/jackc/pgproto3/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ module github.com/jackc/pgproto3/v2
|
|||||||
go 1.12
|
go 1.12
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/jackc/chunkreader v1.0.0
|
|
||||||
github.com/jackc/chunkreader/v2 v2.0.0
|
github.com/jackc/chunkreader/v2 v2.0.0
|
||||||
github.com/jackc/pgio v1.0.0
|
github.com/jackc/pgio v1.0.0
|
||||||
github.com/pkg/errors v0.8.1
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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 h1:DUwgMQuuPnS0rhMXenUtZpqZqrR/30NWY+qQvTpSvEs=
|
||||||
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
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 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
|
||||||
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
|
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=
|
|
||||||
|
|||||||
+3
-3
@@ -3,9 +3,9 @@ package pgproto3
|
|||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/jackc/pgio"
|
"github.com/jackc/pgio"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const sslRequestNumber = 80877103
|
const sslRequestNumber = 80877103
|
||||||
@@ -18,13 +18,13 @@ func (*SSLRequest) Frontend() {}
|
|||||||
|
|
||||||
func (dst *SSLRequest) Decode(src []byte) error {
|
func (dst *SSLRequest) Decode(src []byte) error {
|
||||||
if len(src) < 4 {
|
if len(src) < 4 {
|
||||||
return errors.Errorf("ssl request too short")
|
return errors.New("ssl request too short")
|
||||||
}
|
}
|
||||||
|
|
||||||
requestCode := binary.BigEndian.Uint32(src)
|
requestCode := binary.BigEndian.Uint32(src)
|
||||||
|
|
||||||
if requestCode != sslRequestNumber {
|
if requestCode != sslRequestNumber {
|
||||||
return errors.Errorf("bad ssl request code")
|
return errors.New("bad ssl request code")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
+5
-4
@@ -4,9 +4,10 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/jackc/pgio"
|
"github.com/jackc/pgio"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const ProtocolVersionNumber = 196608 // 3.0
|
const ProtocolVersionNumber = 196608 // 3.0
|
||||||
@@ -23,14 +24,14 @@ func (*StartupMessage) Frontend() {}
|
|||||||
// type identifier and 4 byte message length.
|
// type identifier and 4 byte message length.
|
||||||
func (dst *StartupMessage) Decode(src []byte) error {
|
func (dst *StartupMessage) Decode(src []byte) error {
|
||||||
if len(src) < 4 {
|
if len(src) < 4 {
|
||||||
return errors.Errorf("startup message too short")
|
return errors.New("startup message too short")
|
||||||
}
|
}
|
||||||
|
|
||||||
dst.ProtocolVersion = binary.BigEndian.Uint32(src)
|
dst.ProtocolVersion = binary.BigEndian.Uint32(src)
|
||||||
rp := 4
|
rp := 4
|
||||||
|
|
||||||
if dst.ProtocolVersion != ProtocolVersionNumber {
|
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)
|
dst.Parameters = make(map[string]string)
|
||||||
@@ -53,7 +54,7 @@ func (dst *StartupMessage) Decode(src []byte) error {
|
|||||||
|
|
||||||
if len(src[rp:]) == 1 {
|
if len(src[rp:]) == 1 {
|
||||||
if src[rp] != 0 {
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user