Home | History | Annotate | Download | only in os
      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 var executablePath string // set by ../runtime/os_darwin.go
      8 
      9 var initCwd, initCwdErr = Getwd()
     10 
     11 func 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 }
     25