/
detectenv.go
executable file
·105 lines (87 loc) · 2.54 KB
/
detectenv.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com
// Env represents environment variables
type Env struct {
GoBBQRoot string
}
// // GetDispatcherDir returns the path to the dispatcher
// func (env *Env) GetDispatcherDir() string {
// return filepath.Join(env.GoBBQRoot, "components", "dispatcher")
// }
// // GetGateDir returns the path to the gate
// func (env *Env) GetGateDir() string {
// return filepath.Join(env.GoBBQRoot, "components", "gate")
// }
// // GetDispatcherBinary returns the path to the dispatcher binary
// func (env *Env) GetDispatcherBinary() string {
// return filepath.Join(env.GetDispatcherDir(), "dispatcher"+BinaryExtension)
// }
// // GetGateBinary returns the path to the gate binary
// func (env *Env) GetGateBinary() string {
// return filepath.Join(env.GetGateDir(), "gate"+BinaryExtension)
// }
var RunEnv Env
// func getGoSearchPaths() []string {
// var paths []string
// goroot := os.Getenv("GOROOT")
// if goroot != "" {
// paths = append(paths, goroot)
// }
// gopath := os.Getenv("GOPATH")
// for _, p := range strings.Split(gopath, string(os.PathListSeparator)) {
// if p != "" {
// paths = append(paths, p)
// }
// }
// return paths
// }
// type ModuleInfo struct {
// Path string `json:"Path"`
// Main bool `json:"Main"`
// Dir string `json:"Dir"`
// GoMod string `json:"GoMod"`
// GoVersion string `json:"GoVersion"`
// }
// func goListModule() (*ModuleInfo, error) {
// cmd := exec.Command("go", "list", "-m", "-json")
// r, err := cmd.StdoutPipe()
// if err != nil {
// return nil, err
// }
// err = cmd.Start()
// if err != nil {
// return nil, err
// }
// d := json.NewDecoder(r)
// var mi ModuleInfo
// err = d.Decode(&mi)
// if err != nil {
// return nil, err
// }
// cmd.Wait()
// return &mi, err
// }
// func _DetectGoBBQPath() string {
// mi, err := goListModule()
// if err == nil {
// ShowMsg("go list -m -json: %+v", *mi)
// return mi.Dir
// }
// searchPaths := getGoSearchPaths()
// ShowMsg("go search paths: %s", strings.Join(searchPaths, string(os.PathListSeparator)))
// for _, sp := range searchPaths {
// gobbqPath := filepath.Join(sp, "src", "github.com", "0x00b", "gobbq")
// if IsDir(gobbqPath) {
// return gobbqPath
// }
// }
// return ""
// }
// func DetectGoBBQPath() {
// RunEnv.GoBBQRoot = _DetectGoBBQPath()
// if RunEnv.GoBBQRoot == "" {
// ShowMsgAndQuit("gobbq directory is not detected")
// }
// ShowMsg("gobbq directory found: %s", RunEnv.GoBBQRoot)
// configFile := filepath.Join(RunEnv.GoBBQRoot, "gobbq.ini")
// config.SetConfigFile(configFile)
// }