internal/jsonrpc2*: remove usage of golang.org/x/xerrors
As of golang/go#50827, gopls no longer needs to build at Go 1.12. This was the only reason to continue using xerrors in the jsonrpc2 libraries. Remove this usage as a step toward eliminating the xerrors dependency from x/tools. For golang/go#52442 Change-Id: I1a0a1bbf57e6606c66b99b27439adf6f65c26a60 Reviewed-on: https://go-review.googlesource.com/c/tools/+/401155 Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
bc1b54354a
commit
bdd1f89abd
1 changed files with 35 additions and 40 deletions
|
|
@ -6,8 +6,8 @@ package jsonrpc2
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
errors "golang.org/x/xerrors"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ID is a Request identifier.
|
||||
|
|
@ -120,7 +120,7 @@ func EncodeMessage(msg Message) ([]byte, error) {
|
|||
msg.marshal(&wire)
|
||||
data, err := json.Marshal(&wire)
|
||||
if err != nil {
|
||||
return data, errors.Errorf("marshaling jsonrpc message: %w", err)
|
||||
return data, fmt.Errorf("marshaling jsonrpc message: %w", err)
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
|
@ -128,10 +128,10 @@ func EncodeMessage(msg Message) ([]byte, error) {
|
|||
func DecodeMessage(data []byte) (Message, error) {
|
||||
msg := wireCombined{}
|
||||
if err := json.Unmarshal(data, &msg); err != nil {
|
||||
return nil, errors.Errorf("unmarshaling jsonrpc message: %w", err)
|
||||
return nil, fmt.Errorf("unmarshaling jsonrpc message: %w", err)
|
||||
}
|
||||
if msg.VersionTag != wireVersion {
|
||||
return nil, errors.Errorf("invalid message version tag %s expected %s", msg.VersionTag, wireVersion)
|
||||
return nil, fmt.Errorf("invalid message version tag %s expected %s", msg.VersionTag, wireVersion)
|
||||
}
|
||||
id := ID{}
|
||||
switch v := msg.ID.(type) {
|
||||
|
|
@ -144,7 +144,7 @@ func DecodeMessage(data []byte) (Message, error) {
|
|||
case string:
|
||||
id = StringID(v)
|
||||
default:
|
||||
return nil, errors.Errorf("invalid message id type <%T>%v", v, v)
|
||||
return nil, fmt.Errorf("invalid message id type <%T>%v", v, v)
|
||||
}
|
||||
if msg.Method != "" {
|
||||
// has a method, must be a call
|
||||
|
|
|
|||
Loading…
Reference in a new issue