-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunits_ctx.go
56 lines (51 loc) · 986 Bytes
/
units_ctx.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package engine
import (
"os"
"path/filepath"
"strings"
)
var (
execPath string
root string
executable string
ext string
name string
pathSeparator = string(os.PathSeparator)
pathListSeparator = string(os.PathListSeparator)
)
func GetExecPath() string {
return execPath
}
func GetRoot() string {
return root
}
func GetExecutable() string {
return executable
}
func GetExt() string {
return ext
}
func GetName() string {
return name
}
func GetPathSeparator() string {
return pathSeparator
}
func GetPathListSeparator() string {
return pathListSeparator
}
func init() {
var err error
execPath, err = os.Executable()
if err != nil {
execPath, _ = filepath.Abs(os.Args[0])
}
execPath, err = filepath.EvalSymlinks(execPath)
if err != nil {
execPath, _ = filepath.Abs(os.Args[0])
}
root = filepath.Dir(execPath)
_, executable = filepath.Split(execPath)
ext = filepath.Ext(execPath)
name = strings.Replace(executable, ext, "", -1)
}