用户工作空间自动完成
This commit is contained in:
parent
4ff11fb733
commit
fcfe3eb221
|
@ -169,7 +169,8 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// FIXME: 使用 gocode set lib-path 在多工作空间环境下肯定是有问题的,需要考虑其他实现方式
|
// FIXME: 使用 gocode set lib-path 在多工作空间环境下肯定是有问题的,需要考虑其他实现方式
|
||||||
argv := []string{"set", "lib-path", libPath}
|
argv := []string{"set", "lib-path", libPath}
|
||||||
exec.Command("gocode", argv...).Start()
|
cmd := exec.Command("gocode", argv...)
|
||||||
|
cmd.Start()
|
||||||
|
|
||||||
//argv = []string{"set", "autobuild", "true"}
|
//argv = []string{"set", "autobuild", "true"}
|
||||||
//cmd := exec.Command("gocode", argv...)
|
//cmd := exec.Command("gocode", argv...)
|
||||||
|
|
|
@ -199,6 +199,17 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
buf := make([]byte, 1024*8)
|
buf := make([]byte, 1024*8)
|
||||||
count, _ := reader.Read(buf)
|
count, _ := reader.Read(buf)
|
||||||
|
|
||||||
|
if 0 == count { // 说明构建成功,没有错误信息输出
|
||||||
|
go func() { // 运行 go install,生成的库用于 gocode lib-path
|
||||||
|
cmd := exec.Command("go", "install")
|
||||||
|
cmd.Dir = curDir
|
||||||
|
|
||||||
|
setCmdEnv(cmd, username)
|
||||||
|
|
||||||
|
cmd.Start()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
channelRet := map[string]interface{}{}
|
channelRet := map[string]interface{}{}
|
||||||
|
|
||||||
channelRet["output"] = string(buf[:count])
|
channelRet["output"] = string(buf[:count])
|
||||||
|
@ -223,14 +234,9 @@ func setCmdEnv(cmd *exec.Cmd, username string) {
|
||||||
userRepos := strings.Replace(conf.Wide.UserRepos, "{user}", username, -1)
|
userRepos := strings.Replace(conf.Wide.UserRepos, "{user}", username, -1)
|
||||||
userWorkspace := userRepos[:strings.LastIndex(userRepos, "/src")]
|
userWorkspace := userRepos[:strings.LastIndex(userRepos, "/src")]
|
||||||
|
|
||||||
// glog.Infof("User [%s] workspace [%s]", username, userWorkspace)
|
|
||||||
|
|
||||||
masterWorkspace := conf.Wide.Repos[:strings.LastIndex(conf.Wide.Repos, "/src")]
|
|
||||||
// glog.Infof("Master workspace [%s]", masterWorkspace)
|
|
||||||
|
|
||||||
cmd.Env = append(cmd.Env,
|
cmd.Env = append(cmd.Env,
|
||||||
"GOPATH="+os.Getenv("GOPATH")+string(os.PathListSeparator)+
|
"GOPATH="+userWorkspace,
|
||||||
userWorkspace+string(os.PathListSeparator)+
|
"GOOS="+runtime.GOOS,
|
||||||
masterWorkspace,
|
"GOARCH="+runtime.GOARCH,
|
||||||
"GOROOT="+os.Getenv("GOROOT"))
|
"GOROOT="+runtime.GOROOT())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue