-
Notifications
You must be signed in to change notification settings - Fork 956
runtime,os: add os.Executable() for Darwin #4878
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
Conversation
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.
LGTM, other than a single question below.
argString := _string{ | ||
length: length, | ||
ptr: (*byte)(cstr), | ||
} | ||
executablePath := *(*string)(unsafe.Pointer(&argString)) |
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.
Why not executablePath := unsafe.String((*byte)(cstr), length)
?
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.
We still support Go 1.19, and unsafe.String was introduced in Go 1.20.
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.
We don't (yet) use unsafe.String()
in the runtime package, although there is a comment to that effect:
Line 114 in 3e60eeb
// TODO: use unsafe.String instead once we require Go 1.20. |
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.
I see, thanks. I did in fact look up when unsafe.String
was introduced but then went ahead and assumed 1.20 was more than safe. Out of curiosity, is there any reason for keeping support for such a old version of Go?
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.
We could indeed drop support for this older version by now. One consideration might be that Debian bookworm (current stable) uses Go 1.19, dropping support for that means people will need to upgrade the Go version on Debian.
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.
LGTM assuming you've tested this
Hmm..
Big Go gives the full path but we only get the relative path for a full binary. I should probably fix that. |
Thanks for the addition @dgryski and to @eliasnaur and @aykevl for reviewing. Now merging. |
@dgryski I suspect the result is wrong if you call |
Oops, oh right. I guess we need to do the entire resolution at process startup instead. I'll rework this (although it means adding in a hook to |
Fix for |
No description provided.