Skip to content

[v12] fix: use errors.Is for all EOF comparisons#26018

Merged
nklaassen merged 1 commit intobranch/v12from
nklaassen/v12/errors-is-EOF
May 10, 2023
Merged

[v12] fix: use errors.Is for all EOF comparisons#26018
nklaassen merged 1 commit intobranch/v12from
nklaassen/v12/errors-is-EOF

Conversation

@nklaassen
Copy link
Copy Markdown
Contributor

Backport #26012 to branch/v12

This commit updates all err == io.EOF comparisons to use errors.Is(err, io.EOF). This is necessary when the error may have been wrapped and fixes at least one current breakage (in tsh request ls).

golang.org/x/tools/refactor/eg was very handy for this, I used the following template:

package teleport
import (
	"errors"
	"io"
)
func before(err error) bool { return err == io.EOF }
func after(err error) bool  { return errors.Is(err, io.EOF) }

Backport #26012 to branch/v12

This commit updates all `err == io.EOF` comparisons to use
`errors.Is(err, io.EOF)`. This is necessary when the error may have been
wrapped and fixes at least one current breakage (in `tsh request ls`).

`golang.org/x/tools/refactor/eg` was very handy for this, I used the
following template:

```go
package teleport
import (
	"errors"
	"io"
)
func before(err error) bool { return err == io.EOF }
func after(err error) bool  { return errors.Is(err, io.EOF) }
```
@nklaassen nklaassen requested review from rosstimothy and zmb3 May 10, 2023 19:47
@nklaassen nklaassen enabled auto-merge May 10, 2023 19:49
@nklaassen nklaassen added this pull request to the merge queue May 10, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 10, 2023
@nklaassen nklaassen added this pull request to the merge queue May 10, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 10, 2023
@nklaassen nklaassen added this pull request to the merge queue May 10, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 10, 2023
@nklaassen nklaassen added this pull request to the merge queue May 10, 2023
Merged via the queue into branch/v12 with commit 81d562a May 10, 2023
@nklaassen nklaassen deleted the nklaassen/v12/errors-is-EOF branch May 10, 2023 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants