github.com/code-reading/golang@v0.0.0-20220303082512-ba5bc0e589a3/go/src/os/executable_plan9.go (about) 1 // Copyright 2016 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 //go:build plan9 6 // +build plan9 7 8 package os 9 10 import ( 11 "internal/itoa" 12 "syscall" 13 ) 14 15 func executable() (string, error) { 16 fn := "/proc/" + itoa.Itoa(Getpid()) + "/text" 17 f, err := Open(fn) 18 if err != nil { 19 return "", err 20 } 21 defer f.Close() 22 return syscall.Fd2path(int(f.Fd())) 23 }