Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Use errors.Is/errors.As instead of == comparisons against errors#83

Closed
bahrmichael wants to merge 1 commit into
mastersourcegraph/go-diff:masterfrom
errors-is-as-migration-7f3a1csourcegraph/go-diff:errors-is-as-migration-7f3a1cCopy head branch name to clipboard
Closed

Use errors.Is/errors.As instead of == comparisons against errors#83
bahrmichael wants to merge 1 commit into
mastersourcegraph/go-diff:masterfrom
errors-is-as-migration-7f3a1csourcegraph/go-diff:errors-is-as-migration-7f3a1cCopy head branch name to clipboard

Conversation

@bahrmichael

Copy link
Copy Markdown

This change replaces direct ==/!= comparisons against error values with the
standard library helpers errors.Is (for sentinel error values) and errors.As
(for error types).

Direct comparison breaks when an error is wrapped (e.g. with fmt.Errorf("...: %w", err)),
whereas errors.Is/errors.As traverse the wrap chain.

Notes:

  • Comparisons against nil are intentionally left unchanged.
  • Test files, vendored code, and generated code were not modified.

Created by Sourcegraph batch change bahrmichael/432ac474-d2a7-4950-b17f-2a1b1fe59e87.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.