github.com/equinox-io/equinox@v1.2.1-0.20200723040547-60ffe7f858fe/internal/osext/osext.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 // Extensions to the standard "os" package. 6 package osext 7 8 import "path/filepath" 9 10 // Executable returns an absolute path that can be used to 11 // re-invoke the current program. 12 // It may not be valid after the current program exits. 13 func Executable() (string, error) { 14 p, err := executable() 15 return filepath.Clean(p), err 16 } 17 18 // Returns same path as Executable, returns just the folder 19 // path. Excludes the executable name and any trailing slash. 20 func ExecutableFolder() (string, error) { 21 p, err := Executable() 22 if err != nil { 23 return "", err 24 } 25 26 return filepath.Dir(p), nil 27 }