Update kardianos/osext (ref #1272)
This commit is contained in:
parent
435afa0eea
commit
37aa89b19d
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/syncthing/syncthing",
|
"ImportPath": "github.com/syncthing/syncthing",
|
||||||
"GoVersion": "go1.5.1",
|
"GoVersion": "go1.5.2",
|
||||||
"Packages": [
|
"Packages": [
|
||||||
"./cmd/..."
|
"./cmd/..."
|
||||||
],
|
],
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/kardianos/osext",
|
"ImportPath": "github.com/kardianos/osext",
|
||||||
"Rev": "345163ffe35aa66560a4cd7dddf00f3ae21c9fda"
|
"Rev": "431e263e413efe4446ede50cec4819b26659fbe7"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/rcrowley/go-metrics",
|
"ImportPath": "github.com/rcrowley/go-metrics",
|
||||||
|
|
|
@ -7,12 +7,18 @@ package osext
|
||||||
|
|
||||||
import "path/filepath"
|
import "path/filepath"
|
||||||
|
|
||||||
|
var cx, ce = executableClean()
|
||||||
|
|
||||||
|
func executableClean() (string, error) {
|
||||||
|
p, err := executable()
|
||||||
|
return filepath.Clean(p), err
|
||||||
|
}
|
||||||
|
|
||||||
// Executable returns an absolute path that can be used to
|
// Executable returns an absolute path that can be used to
|
||||||
// re-invoke the current program.
|
// re-invoke the current program.
|
||||||
// It may not be valid after the current program exits.
|
// It may not be valid after the current program exits.
|
||||||
func Executable() (string, error) {
|
func Executable() (string, error) {
|
||||||
p, err := executable()
|
return cx, ce
|
||||||
return filepath.Clean(p), err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns same path as Executable, returns just the folder
|
// Returns same path as Executable, returns just the folder
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build linux netbsd solaris dragonfly
|
// +build linux netbsd solaris dragonfly freebsd
|
||||||
|
|
||||||
package osext
|
package osext
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ func executable() (string, error) {
|
||||||
return execpath, nil
|
return execpath, nil
|
||||||
case "netbsd":
|
case "netbsd":
|
||||||
return os.Readlink("/proc/curproc/exe")
|
return os.Readlink("/proc/curproc/exe")
|
||||||
|
case "freebsd":
|
||||||
|
return os.Readlink("/proc/curproc/file")
|
||||||
case "dragonfly":
|
case "dragonfly":
|
||||||
return os.Readlink("/proc/curproc/file")
|
return os.Readlink("/proc/curproc/file")
|
||||||
case "solaris":
|
case "solaris":
|
||||||
|
|
Loading…
Reference in New Issue