tree: 224af132b6f1006dee7f2317dedd28ae276a7a48 [path history] [tgz]
  3. osext.go
  4. osext_go18.go
  5. osext_plan9.go
  6. osext_procfs.go
  7. osext_sysctl.go
  8. osext_windows.go

Extensions to the “os” package.


Find the current Executable and ExecutableFolder.

As of go1.8 the Executable function may be found in os. The Executable function in the std lib os package is used if available.

There is sometimes utility in finding the current executable file that is running. This can be used for upgrading the current executable or finding resources located relative to the executable file. Both working directory and the os.Args[0] value are arbitrary and cannot be relied on; os.Args[0] can be “faked”.

Multi-platform and supports:

  • Linux
  • OS X
  • Windows
  • Plan 9
  • BSDs.