syncthing/Godeps/_workspace/src/github.com/kardianos/osext/osext.go

28 lines
743 B
Go
Raw Normal View History

2014-05-02 08:05:48 +00:00
// 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
2015-06-15 19:10:18 +00:00
// path. Excludes the executable name and any trailing slash.
2014-05-02 08:05:48 +00:00
func ExecutableFolder() (string, error) {
p, err := Executable()
if err != nil {
return "", err
}
2015-06-15 19:10:18 +00:00
return filepath.Dir(p), nil
2014-05-02 08:05:48 +00:00
}