-
Notifications
You must be signed in to change notification settings - Fork 236
cmd/root, pkg/utils: Use errors.Is() instead of os.IsNotExist() #1629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
debarshiray
merged 2 commits into
containers:main
from
debarshiray:wip/rishi/pkg-utils-use-errors-Is-not-os-IsNotExist
Apr 28, 2025
Merged
cmd/root, pkg/utils: Use errors.Is() instead of os.IsNotExist() #1629
debarshiray
merged 2 commits into
containers:main
from
debarshiray:wip/rishi/pkg-utils-use-errors-Is-not-os-IsNotExist
Apr 28, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
debarshiray
added a commit
to debarshiray/toolbox
that referenced
this pull request
Apr 25, 2025
The os.IsNotExist() function [1] predates the introduction of the errors.Is() function [2] in Go 1.13 [3]. From Go >= 1.16, the documentation explicitly recommends the use of errors.Is() instead of os.IsNotExist() [4]. The Go implementation of Toolbx never used any Go older than 1.13 [5], and currently it requires Go >= 1.21 [6]. So, there's no reason not to use the more modern and recommended alternative. [1] https://pkg.go.dev/os#IsNotExist [2] https://pkg.go.dev/errors#Is [3] https://go.dev/blog/go1.13-errors [4] Go commit b641f0dcf48aa748 golang/go@b641f0dcf48aa748 golang/go#41122 [5] Commit d857471 containers@d857471aa2f233e5 containers#318 [6] Commit 82e85ba containers@82e85bac9f5e69a5 containers#1614 containers#1629
4d50cc3
to
e17b729
Compare
recheck |
e17b729
to
e9e77fb
Compare
The os.IsNotExist() function [1] predates the introduction of the errors.Is() function [2] in Go 1.13 [3]. From Go >= 1.16, the documentation explicitly recommends the use of errors.Is() instead of os.IsNotExist() [4]. The Go implementation of Toolbx never used any Go older than 1.13 [5], and currently it requires Go >= 1.21 [6]. So, there's no reason not to use the more modern and recommended alternative. [1] https://pkg.go.dev/os#IsNotExist [2] https://pkg.go.dev/errors#Is [3] https://go.dev/blog/go1.13-errors [4] Go commit b641f0dcf48aa748 golang/go@b641f0dcf48aa748 golang/go#41122 [5] Commit d857471 containers@d857471aa2f233e5 containers#318 [6] Commit 82e85ba containers@82e85bac9f5e69a5 containers#1614 containers#1629
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
os.IsNotExist()
function [1] predates the introduction of theerrors.Is()
function [2] in Go 1.13 [3]. From Go >= 1.16, thedocumentation explicitly recommends the use of
errors.Is()
instead ofos.IsNotExist()
[4].The Go implementation of Toolbx never used any Go older than 1.13 [5],
and currently it requires Go >= 1.21 [6]. So, there's no reason not to
use the more modern and recommended alternative.
[1] https://pkg.go.dev/os#IsNotExist
[2] https://pkg.go.dev/errors#Is
[3] https://go.dev/blog/go1.13-errors
[4] Go commit b641f0dcf48aa748
golang/go@b641f0dcf48aa748
golang/go#41122
[5] Commit d857471
d857471aa2f233e5
#318
[6] Commit 82e85ba
82e85bac9f5e69a5
#1614