This commit is contained in:
Liang Ding 2014-10-26 14:46:15 +08:00
parent 0a10cf2689
commit 3b8b8ced46
2 changed files with 25 additions and 11 deletions

View File

@ -124,13 +124,15 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
// glog.Infof("offset: %d", offset)
userWorkspace := conf.Wide.GetUserWorkspace(username)
workspaces := strings.Split(userWorkspace, conf.PathListSeparator)
libPath := ""
for _, workspace := range workspaces {
userLib := workspace + conf.PathSeparator + "pkg" + conf.PathSeparator +
runtime.GOOS + "_" + runtime.GOARCH
libPath += userLib + conf.PathListSeparator
}
//glog.Infof("User [%s] workspace [%s]", username, userWorkspace)
userLib := userWorkspace + conf.PathSeparator + "pkg" + conf.PathSeparator +
runtime.GOOS + "_" + runtime.GOARCH
libPath := userLib
//glog.Infof("gocode set lib-path %s", libPath)
glog.V(5).Infof("gocode set lib-path %s", libPath)
// FIXME: 使用 gocode set lib-path 在多工作空间环境下肯定是有问题的,需要考虑其他实现方式
gocode := conf.Wide.GetGocode()

View File

@ -45,9 +45,24 @@ func GetFiles(w http.ResponseWriter, r *http.Request) {
session, _ := session.HTTPSession.Get(r, "wide-session")
username := session.Values["username"].(string)
userSrc := conf.Wide.GetUserWorkspace(username) + conf.PathSeparator + "src"
userWorkspace := conf.Wide.GetUserWorkspace(username)
workspaces := strings.Split(userWorkspace, conf.PathListSeparator)
root := FileNode{Name: "projects", Path: userSrc, IconSkin: "ico-ztree-dir ", Type: "d", FileNodes: []*FileNode{}}
root := FileNode{Name: "root", Path: "", IconSkin: "ico-ztree-dir ", Type: "d", FileNodes: []*FileNode{}}
// 工作空间节点处理
for _, workspace := range workspaces {
workspacePath := workspace + conf.PathSeparator + "src"
workspaceNode := FileNode{Name: workspace[strings.LastIndex(workspace, conf.PathSeparator)+1:] + " (" +
workspace + ")",
Path: workspacePath, IconSkin: "ico-ztree-dir ", Type: "d", FileNodes: []*FileNode{}}
walk(workspacePath, &workspaceNode)
// 添加工作空间节点
root.FileNodes = append(root.FileNodes, &workspaceNode)
}
// 构造 Go API 节点
apiPath := runtime.GOROOT() + conf.PathSeparator + "src" + conf.PathSeparator + "pkg"
@ -65,9 +80,6 @@ func GetFiles(w http.ResponseWriter, r *http.Request) {
close(goapiBuildOKSignal)
}()
// 构造用户工作空间文件树
walk(userSrc, &root)
// 等待放行
<-goapiBuildOKSignal