go/packages: remove usage of golang.org/x/xerrors

As of golang/go#50827, gopls no longer needs to build at Go 1.12. I
believe this was the only reason to continue using xerrors in
go/packages.

Remove this usage as a step toward eliminating the xerrors dependency
from x/tools.

For golang/go#52442

Change-Id: I8f7396491be58606be6a648ebbf2180bdbc907b5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/401154
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@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Robert Findley 2022-04-19 18:34:47 -04:00
parent 37590b385d
commit bcfc38ff69
2 changed files with 3 additions and 5 deletions

View File

@ -26,7 +26,6 @@ import (
"golang.org/x/tools/go/internal/packagesdriver"
"golang.org/x/tools/internal/gocommand"
"golang.org/x/tools/internal/packagesinternal"
"golang.org/x/xerrors"
)
// debug controls verbose logging.
@ -953,7 +952,7 @@ func (state *golistState) invokeGo(verb string, args ...string) (*bytes.Buffer,
if !ok {
// Catastrophic error:
// - context cancellation
return nil, xerrors.Errorf("couldn't run 'go': %w", err)
return nil, fmt.Errorf("couldn't run 'go': %w", err)
}
// Old go version?

View File

@ -81,7 +81,6 @@ import (
"golang.org/x/tools/go/packages"
"golang.org/x/tools/internal/span"
"golang.org/x/tools/internal/testenv"
"golang.org/x/xerrors"
)
var (
@ -247,7 +246,7 @@ func Export(t testing.TB, exporter Exporter, modules []Module) *Exported {
switch value := value.(type) {
case Writer:
if err := value(fullpath); err != nil {
if xerrors.Is(err, ErrUnsupported) {
if errors.Is(err, ErrUnsupported) {
t.Skip(err)
}
t.Fatal(err)
@ -339,7 +338,7 @@ func Symlink(source string) Writer {
mode := os.ModePerm
if err == nil {
mode = stat.Mode()
} else if !xerrors.Is(err, os.ErrNotExist) {
} else if !errors.Is(err, os.ErrNotExist) {
// We couldn't open the source, but it might exist. We don't expect to be
// able to portably create a symlink to a file we can't see.
return symlinkErr