Fix #94
This commit is contained in:
parent
3b8b8ced46
commit
107b499f1a
54
conf/wide.go
54
conf/wide.go
|
@ -83,7 +83,7 @@ func FixedTimeCheckEnv() {
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
gocode := Wide.GetGocode()
|
gocode := Wide.GetExecutableInGOBIN("gocode")
|
||||||
cmd := exec.Command(gocode, "close")
|
cmd := exec.Command(gocode, "close")
|
||||||
_, err := cmd.Output()
|
_, err := cmd.Output()
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
@ -91,7 +91,7 @@ func FixedTimeCheckEnv() {
|
||||||
glog.Warningf("Not found gocode [%s]", gocode)
|
glog.Warningf("Not found gocode [%s]", gocode)
|
||||||
}
|
}
|
||||||
|
|
||||||
ide_stub := Wide.GetIDEStub()
|
ide_stub := Wide.GetExecutableInGOBIN("ide_stub")
|
||||||
cmd = exec.Command(ide_stub, "version")
|
cmd = exec.Command(ide_stub, "version")
|
||||||
_, err = cmd.Output()
|
_, err = cmd.Output()
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
@ -149,40 +149,40 @@ func (*conf) GetUser(username string) *User {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取 gocode 路径.
|
// 获取 GOBIN 中 executable 指定的文件路径.
|
||||||
func (*conf) GetGocode() string {
|
//
|
||||||
return getGOBIN() + "gocode"
|
// 函数内部会判断操作系统,如果是 Windows 则在 executable 实参后加入 .exe 后缀.
|
||||||
|
func (*conf) GetExecutableInGOBIN(executable string) string {
|
||||||
|
if util.OS.IsWindows() {
|
||||||
|
executable += ".exe"
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取 ide_stub 路径.
|
gopaths := strings.Split(os.Getenv("GOPATH"), PathListSeparator)
|
||||||
func (*conf) GetIDEStub() string {
|
|
||||||
return getGOBIN() + "ide_stub"
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取 GOBIN 路径,末尾带路径分隔符.
|
for _, gopath := range gopaths {
|
||||||
func getGOBIN() string {
|
// $GOPATH/bin/$GOOS_$GOARCH/executable
|
||||||
// $GOBIN/
|
ret := gopath + PathSeparator + "bin" + PathSeparator +
|
||||||
ret := os.Getenv("GOBIN")
|
os.Getenv("GOOS") + "_" + os.Getenv("GOARCH") + PathSeparator + executable
|
||||||
if "" != ret {
|
|
||||||
return ret + PathSeparator
|
|
||||||
}
|
|
||||||
|
|
||||||
// $GOPATH/bin/$GOOS_$GOARCH/
|
|
||||||
ret = os.Getenv("GOPATH") + PathSeparator + "bin" + PathSeparator +
|
|
||||||
os.Getenv("GOOS") + "_" + os.Getenv("GOARCH")
|
|
||||||
if isExist(ret) {
|
if isExist(ret) {
|
||||||
return ret + PathSeparator
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
// $GOPATH/bin/{runtime.GOOS}_{runtime.GOARCH}/
|
// $GOPATH/bin/{runtime.GOOS}_{runtime.GOARCH}/executable
|
||||||
ret = os.Getenv("GOPATH") + PathSeparator + "bin" + PathSeparator +
|
ret = gopath + PathSeparator + "bin" + PathSeparator +
|
||||||
runtime.GOOS + "_" + runtime.GOARCH
|
runtime.GOOS + "_" + runtime.GOARCH + PathSeparator + executable
|
||||||
if isExist(ret) {
|
if isExist(ret) {
|
||||||
return ret + PathSeparator
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
// $GOPATH/bin/
|
// $GOPATH/bin/executable
|
||||||
return os.Getenv("GOPATH") + PathSeparator + "bin" + PathSeparator
|
ret = gopath + PathSeparator + "bin" + PathSeparator + executable
|
||||||
|
if isExist(ret) {
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// $GOBIN/executable
|
||||||
|
return os.Getenv("GOBIN") + PathSeparator + executable
|
||||||
}
|
}
|
||||||
|
|
||||||
< |