]> Cypherpunks.ru repositories - gostls13.git/blob - src/os/executable_solaris.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / src / os / executable_solaris.go
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 package os
6
7 import "syscall"
8
9 var executablePath string // set by sysauxv in ../runtime/os3_solaris.go
10
11 var initCwd, initCwdErr = Getwd()
12
13 func executable() (string, error) {
14         path := executablePath
15         if len(path) == 0 {
16                 path, err := syscall.Getexecname()
17                 if err != nil {
18                         return path, err
19                 }
20         }
21         if len(path) > 0 && path[0] != '/' {
22                 if initCwdErr != nil {
23                         return path, initCwdErr
24                 }
25                 if len(path) > 2 && path[0:2] == "./" {
26                         // skip "./"
27                         path = path[2:]
28                 }
29                 return initCwd + "/" + path, nil
30         }
31         return path, nil
32 }