github.com/cellofellow/gopkg@v0.0.0-20140722061823-eec0544a62ad/osext/path.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 package osext 6 7 import "path/filepath" 8 9 // Executable returns an absolute path that can be used to 10 // re-invoke the current program. 11 // It may not be valid after the current program exits. 12 func Executable() (string, error) { 13 p, err := executable() 14 return filepath.Clean(p), err 15 } 16 17 // Returns same path as Executable, returns just the folder 18 // path. Excludes the executable name. 19 func ExecutableFolder() (string, error) { 20 p, err := Executable() 21 if err != nil { 22 return "", err 23 } 24 folder, _ := filepath.Split(p) 25 return folder, nil 26 } 27 28 // Depricated. Same as Executable(). 29 func GetExePath() (exePath string, err error) { 30 return Executable() 31 }