Skip to content

Commit

Permalink
refactor(process): compare error with errors.Is
Browse files Browse the repository at this point in the history
Starting from Go 1.13, `errors.Is` is the preferable way to compare
error equality [1].

[1]: https://go.dev/blog/go1.13-errors

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
  • Loading branch information
Juneezee committed Apr 24, 2023
1 parent 17fac7c commit 0439039
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion process/process_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
if err == nil {
return true, nil
}
if err.Error() == "os: process already finished" {
if errors.Is(err, os.ErrProcessDone) {
return false, nil
}
var errno syscall.Errno
Expand Down

0 comments on commit 0439039

Please sign in to comment.