This commit is contained in:
Liang Ding 2014-09-05 11:24:53 +08:00
parent 932d472c0d
commit 533434fe43
3 changed files with 13 additions and 5 deletions

View File

@ -36,6 +36,14 @@ type conf struct {
var Wide conf
var rawWide conf
func (this *conf) GetWorkspace() string {
return filepath.FromSlash(this.Workspace)
}
func (this *conf) GetUserWorkspace(username string) string {
return filepath.FromSlash(this.UserWorkspaces) + string(os.PathSeparator) + username
}
func Save() bool {
// 可变部分
rawWide.Users = Wide.Users

View File

@ -21,12 +21,12 @@ func GetFiles(w http.ResponseWriter, r *http.Request) {
session, _ := user.Session.Get(r, "wide-session")
username := session.Values["username"].(string)
userRepos := conf.Wide.UserWorkspaces + string(os.PathSeparator) + username + string(os.PathSeparator) + "src"
userSrc := conf.Wide.GetUserWorkspace(username) + string(os.PathSeparator) + "src"
root := FileNode{"projects", userRepos, "d", []*FileNode{}}
fileInfo, _ := os.Lstat(userRepos)
root := FileNode{"projects", userSrc, "d", []*FileNode{}}
fileInfo, _ := os.Lstat(userSrc)
walk(userRepos, fileInfo, &root)
walk(userSrc, fileInfo, &root)
data["root"] = root
}

View File

@ -231,7 +231,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
}
func setCmdEnv(cmd *exec.Cmd, username string) {
userWorkspace := conf.Wide.UserWorkspaces + string(os.PathSeparator) + username
userWorkspace := conf.Wide.GetUserWorkspace(username)
cmd.Env = append(cmd.Env,
"GOPATH="+userWorkspace,