github.com/zignig/go-ipfs@v0.0.0-20141111235910-c9e5fdf55a52/Godeps/_workspace/src/bitbucket.org/kardianos/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.
    20  func ExecutableFolder() (string, error) {
    21  	p, err := Executable()
    22  	if err != nil {
    23  		return "", err
    24  	}
    25  	folder, _ := filepath.Split(p)
    26  	return folder, nil
    27  }
    28  
    29  // Depricated. Same as Executable().
    30  func GetExePath() (exePath string, err error) {
    31  	return Executable()
    32  }