Skip to content

Commit 81faa3e

Browse files
author
zounengren
committed
replace pkg/errors from vendor
Signed-off-by: Zou Nengren <[email protected]>
1 parent 360e86c commit 81faa3e

11 files changed

Lines changed: 30 additions & 30 deletions

File tree

channel.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ package ttrpc
1919
import (
2020
"bufio"
2121
"encoding/binary"
22+
"fmt"
2223
"io"
2324
"net"
2425
"sync"
2526

26-
"github.com/pkg/errors"
2727
"google.golang.org/grpc/codes"
2828
"google.golang.org/grpc/status"
2929
)
@@ -105,15 +105,15 @@ func (ch *channel) recv() (messageHeader, []byte, error) {
105105

106106
if mh.Length > uint32(messageLengthMax) {
107107
if _, err := ch.br.Discard(int(mh.Length)); err != nil {
108-
return mh, nil, errors.Wrapf(err, "failed to discard after receiving oversized message")
108+
return mh, nil, fmt.Errorf("failed to discard after receiving oversized message: %w", err)
109109
}
110110

111111
return mh, nil, status.Errorf(codes.ResourceExhausted, "message length %v exceed maximum message size of %v", mh.Length, messageLengthMax)
112112
}
113113

114114
p := ch.getmbuf(int(mh.Length))
115115
if _, err := io.ReadFull(ch.br, p); err != nil {
116-
return messageHeader{}, nil, errors.Wrapf(err, "failed reading message")
116+
return messageHeader{}, nil, fmt.Errorf("failed reading message: %w", err)
117117
}
118118

119119
return mh, p, nil

channel_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ package ttrpc
1818

1919
import (
2020
"bytes"
21+
"errors"
2122
"io"
2223
"net"
2324
"reflect"
2425
"testing"
2526

26-
"github.com/pkg/errors"
2727
"google.golang.org/grpc/codes"
2828
"google.golang.org/grpc/status"
2929
)
@@ -56,7 +56,7 @@ func TestReadWriteMessage(t *testing.T) {
5656
for {
5757
_, p, err := rch.recv()
5858
if err != nil {
59-
if errors.Cause(err) != io.EOF {
59+
if !errors.Is(err, io.EOF) {
6060
t.Fatal(err)
6161
}
6262

client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package ttrpc
1818

1919
import (
2020
"context"
21+
"errors"
2122
"io"
2223
"net"
2324
"os"
@@ -27,7 +28,6 @@ import (
2728
"time"
2829

2930
"github.com/gogo/protobuf/proto"
30-
"github.com/pkg/errors"
3131
"github.com/sirupsen/logrus"
3232
"google.golang.org/grpc/codes"
3333
"google.golang.org/grpc/status"
@@ -347,7 +347,7 @@ func filterCloseErr(err error) error {
347347
return nil
348348
case err == io.EOF:
349349
return ErrClosed
350-
case errors.Cause(err) == io.EOF:
350+
case errors.Is(err, io.EOF):
351351
return ErrClosed
352352
case strings.Contains(err.Error(), "use of closed network connection"):
353353
return ErrClosed

codec.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
package ttrpc
1818

1919
import (
20+
"fmt"
21+
2022
"github.com/gogo/protobuf/proto"
21-
"github.com/pkg/errors"
2223
)
2324

2425
type codec struct{}
@@ -28,7 +29,7 @@ func (c codec) Marshal(msg interface{}) ([]byte, error) {
2829
case proto.Message:
2930
return proto.Marshal(v)
3031
default:
31-
return nil, errors.Errorf("ttrpc: cannot marshal unknown type: %T", msg)
32+
return nil, fmt.Errorf("ttrpc: cannot marshal unknown type: %T", msg)
3233
}
3334
}
3435

@@ -37,6 +38,6 @@ func (c codec) Unmarshal(p []byte, msg interface{}) error {
3738
case proto.Message:
3839
return proto.Unmarshal(p, v)
3940
default:
40-
return errors.Errorf("ttrpc: cannot unmarshal into unknown type: %T", msg)
41+
return fmt.Errorf("ttrpc: cannot unmarshal into unknown type: %T", msg)
4142
}
4243
}

config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package ttrpc
1818

19-
import "github.com/pkg/errors"
19+
import "errors"
2020

2121
type serverConfig struct {
2222
handshaker Handshaker

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ go 1.13
44

55
require (
66
github.com/gogo/protobuf v1.3.2
7-
github.com/pkg/errors v0.9.1
87
github.com/prometheus/procfs v0.6.0
9-
github.com/sirupsen/logrus v1.7.0
8+
github.com/sirupsen/logrus v1.8.1
109
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
1110
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63
1211
google.golang.org/grpc v1.27.1

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
2020
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
2121
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
2222
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
23-
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
24-
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
2523
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2624
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2725
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
2826
github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
2927
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
30-
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
31-
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
28+
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
29+
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
3230
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
3331
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
3432
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ package ttrpc
1818

1919
import (
2020
"context"
21+
"errors"
2122
"io"
2223
"math/rand"
2324
"net"
2425
"sync"
2526
"sync/atomic"
2627
"time"
2728

28-
"github.com/pkg/errors"
2929
"github.com/sirupsen/logrus"
3030
"google.golang.org/grpc/codes"
3131
"google.golang.org/grpc/status"

server_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package ttrpc
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223
"net"
2324
"reflect"
@@ -28,7 +29,6 @@ import (
2829
"time"
2930

3031
"github.com/gogo/protobuf/proto"
31-
"github.com/pkg/errors"
3232
"google.golang.org/grpc/codes"
3333
"google.golang.org/grpc/status"
3434
)
@@ -361,8 +361,8 @@ func TestClientEOF(t *testing.T) {
361361
// server shutdown, but we still make a call.
362362
if err := client.Call(ctx, serviceName, "Test", tp, tp); err == nil {
363363
t.Fatalf("expected error when calling against shutdown server")
364-
} else if errors.Cause(err) != ErrClosed {
365-
t.Fatalf("expected to have a cause of ErrClosed, got %v", errors.Cause(err))
364+
} else if !errors.Is(err, ErrClosed) {
365+
t.Fatalf("expected to have a cause of ErrClosed, got %v", err)
366366
}
367367
}
368368

services.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ package ttrpc
1818

1919
import (
2020
"context"
21+
"errors"
22+
"fmt"
2123
"io"
2224
"os"
2325
"path"
2426
"unsafe"
2527

2628
"github.com/gogo/protobuf/proto"
27-
"github.com/pkg/errors"
2829
"google.golang.org/grpc/codes"
2930
"google.golang.org/grpc/status"
3031
)
@@ -51,7 +52,7 @@ func newServiceSet(interceptor UnaryServerInterceptor) *serviceSet {
5152

5253
func (s *serviceSet) register(name string, methods map[string]Method) {
5354
if _, ok := s.services[name]; ok {
54-
panic(errors.Errorf("duplicate service %v registered", name))
55+
panic(fmt.Errorf("duplicate service %v registered", name))
5556
}
5657

5758
s.services[name] = ServiceDesc{

0 commit comments

Comments
 (0)