diff options
Diffstat (limited to 'modules/base')
-rw-r--r-- | modules/base/base.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/base/base.go b/modules/base/base.go index 864ede055f..c9875fb507 100644 --- a/modules/base/base.go +++ b/modules/base/base.go @@ -4,6 +4,12 @@ package base +import ( + "os" + "os/exec" + "path/filepath" +) + const DOC_URL = "https://github.com/gogits/go-gogs-client/wiki" type ( @@ -11,3 +17,16 @@ type ( ) var GoGetMetas = make(map[string]bool) + +// ExecPath returns the executable path. +func ExecPath() (string, error) { + file, err := exec.LookPath(os.Args[0]) + if err != nil { + return "", err + } + p, err := filepath.Abs(file) + if err != nil { + return "", err + } + return p, nil +} |