osext_procfs.go 553 B

12345678910111213141516171819202122232425
  1. // Copyright 2012 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build linux netbsd openbsd
  5. package osext
  6. import (
  7. "errors"
  8. "os"
  9. "runtime"
  10. )
  11. func executable() (string, error) {
  12. switch runtime.GOOS {
  13. case "linux":
  14. return os.Readlink("/proc/self/exe")
  15. case "netbsd":
  16. return os.Readlink("/proc/curproc/exe")
  17. case "openbsd":
  18. return os.Readlink("/proc/curproc/file")
  19. }
  20. return "", errors.New("ExecPath not implemented for " + runtime.GOOS)
  21. }