aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/bitbucket.org/kardianos/osext/osext.go
blob: 37efbb221085fe3bab00692cfc047b60d7541067 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Extensions to the standard "os" package.
package osext

import "path/filepath"

// Executable returns an absolute path that can be used to
// re-invoke the current program.
// It may not be valid after the current program exits.
func Executable() (string, error) {
    p, err := executable()
    return filepath.Clean(p), err
}

// Returns same path as Executable, returns just the folder
// path. Excludes the executable name.
func ExecutableFolder() (string, error) {
    p, err := Executable()
    if err != nil {
        return "", err
    }
    folder, _ := filepath.Split(p)
    return folder, nil
}

// Depricated. Same as Executable().
func GetExePath() (exePath string, err error) {
    return Executable()
}