-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
os: provide full path to current executable #4057
Labels
Comments
Comment 3 by uriel@berlinblue.org: By "in general" you mean "in a portable way"? Doesn't seem much less portable than things like os/inotify, and seems to be supported in most platform relatively easily (just reading a symlink in /proc/ or the like), OS X seems like might be the trickiest. |
I've solved the problem on Darwin (without using cgo, of course), a preview CL is at https://golang.org/cl/6736069/. before continue, i'd like to solicit opinions about the new API. package os func ExecPath() (string, error) ExecPath returns the absolute pathname of the current executing file; if error occurs, it will return whatever it current gets and the error. should it be named GetExecPath()? or some other name? i think implementing it for rest of supported OSes (except Plan 9) is easy. Owner changed to @minux. |
https://golang.org/cl/6736069/ Status changed to Started. |
CL 6736069 is rejected mainly because the API whose behavior we can precisely define (finding the path to re-invoke the current executable) is not what people'd expect (finding asset files accompanying the executable). I will extract code from that CL into a separate go-gettable package. Labels changed: added priority-someday, removed priority-later. Owner changed to ---. Status changed to Accepted. |
You could check `osext` package, it's cross platform: http://godoc.org/bitbucket.org/kardianos/osext func Executable() (string, error) Executable returns an absolute path that can be used to re-invoke the current program. It may not be valid after the current program exits. func ExecutableFolder() (string, error) Returns same path as Executable, returns just the folder path. Excludes the executable name. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by lost.goblin:
The text was updated successfully, but these errors were encountered: