github.com/caiguanhao/osext@v0.0.0-20140623154522-4336eed935e0/osext_plan9.go (about) 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 5 package osext 6 7 import ( 8 "syscall" 9 "os" 10 "strconv" 11 ) 12 13 func executable() (string, error) { 14 f, err := os.Open("/proc/" + strconv.Itoa(os.Getpid()) + "/text") 15 if err != nil { 16 return "", err 17 } 18 defer f.Close() 19 return syscall.Fd2path(int(f.Fd())) 20 }