Skip to content

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

Closed
bahrmichael wants to merge 1 commit into
masterfrom
errors-is-as-migration-7f3a1c
Closed

Use errors.Is/errors.As instead of == comparisons against errors#94
bahrmichael wants to merge 1 commit into
masterfrom
errors-is-as-migration-7f3a1c

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