-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.go
48 lines (37 loc) · 860 Bytes
/
common.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
package goui_tools
import (
"github.com/fipress/go-rj"
"os"
"path/filepath"
)
const packageConfigFile = "package.rj"
type packageConfig struct {
Name string
VersionCode int
VersionName string
}
func createPackageConfig(path string) (cfg *packageConfig) {
cfg = &packageConfig{
Name: "GoUIApp Name",
VersionCode: 1,
VersionName: "0.0.1",
}
fullName := filepath.Join(path, packageConfigFile)
rj.MarshalToFile(cfg, fullName)
return
}
func getBinDir() (binDir string, ok bool) {
dir, err := os.Executable()
if err != nil {
getLogger().Error("Get executable directory of GoUI-CLI failed: %s", err.Error())
return
}
dir, err = filepath.EvalSymlinks(dir)
if err != nil {
getLogger().Error("Get executable directory of GoUI-CLI failed: %s", err.Error())
return
}
binDir = filepath.Dir(dir)
ok = true
return
}