Skip to content

Commit

Permalink
go/packages: remove usage of golang.org/x/xerrors
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
findleyr committed Apr 20, 2022
1 parent 37590b3 commit bcfc38f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions go/packages/golist.go
Expand Up @@ -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.
Expand Down Expand Up @@ -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?
Expand Down
5 changes: 2 additions & 3 deletions go/packages/packagestest/export.go
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bcfc38f

Please sign in to comment.