Repository navigation
chore: improve xgo maintenance path #2746
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,11 +35,13 @@ import ( | |
|
|
||
| func checkPathExist(path string, isDir bool) bool { | ||
| stat, err := os.Lstat(path) // Note: os.Lstat() will not follow the symbolic link. | ||
| isExists := !os.IsNotExist(err) | ||
| if err != nil { | ||
| return false | ||
| } | ||
| if isDir { | ||
| return isExists && stat.IsDir() | ||
| return stat.IsDir() | ||
| } | ||
| return isExists && !stat.IsDir() | ||
| return !stat.IsDir() | ||
|
Comment on lines
41
to
+44
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| func trimRight(s string) string { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,11 +27,13 @@ var mainVersionFile = "env/version.go" | |
|
|
||
| func checkPathExist(path string, isDir bool) bool { | ||
| stat, err := os.Stat(path) | ||
| isExists := !os.IsNotExist(err) | ||
| if err != nil { | ||
| return false | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same behavioral change as in |
||
| if isDir { | ||
| return isExists && stat.IsDir() | ||
| return stat.IsDir() | ||
| } | ||
| return isExists && !stat.IsDir() | ||
| return !stat.IsDir() | ||
|
Comment on lines
33
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| func trimRight(s string) string { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change fixes the original nil-dereference risk (the old code would call
stat.IsDir()on anilstatwhenerrwas non-nil but not anIsNotExisterror). However, it now silently treats all errors — includingEACCES/permission denied andEIO— as "path does not exist". Consider adding a comment to make this policy explicit, or handle unexpected errors separately:At minimum, a comment like
// Treat all errors, including permission denied, as non-existencewould make the intent clear.