blob: ce5b8140a4cba651e68e3091d2d85873f308c848 [file] [log] [blame]
Shenghou Ma2fc67e72015-11-01 04:18:58 -05001// 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
5package os
6
7var executablePath string // set by ../runtime/os_darwin.go
8
9var initCwd, initCwdErr = Getwd()
10
11func executable() (string, error) {
12 ep := executablePath
13 if ep[0] != '/' {
14 if initCwdErr != nil {
15 return ep, initCwdErr
16 }
17 if len(ep) > 2 && ep[0:2] == "./" {
18 // skip "./"
19 ep = ep[2:]
20 }
21 ep = initCwd + "/" + ep
22 }
23 return ep, nil
24}