remove 'master workspace'
This commit is contained in:
parent
439c94edd2
commit
c400b82983
18
conf/wide.go
18
conf/wide.go
|
@ -67,7 +67,6 @@ type conf struct {
|
||||||
MaxProcs int // Go max procs
|
MaxProcs int // Go max procs
|
||||||
RuntimeMode string // runtime mode (dev/prod)
|
RuntimeMode string // runtime mode (dev/prod)
|
||||||
WD string // current working direcitory, ${pwd}
|
WD string // current working direcitory, ${pwd}
|
||||||
Workspace string // path of master workspace
|
|
||||||
Locale string // default locale
|
Locale string // default locale
|
||||||
Users []*User // configurations of users
|
Users []*User // configurations of users
|
||||||
}
|
}
|
||||||
|
@ -148,19 +147,6 @@ func (c *conf) GetUserWorkspace(username string) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWorkspace gets the master workspace path.
|
|
||||||
//
|
|
||||||
// Compared to the use of Wide.Workspace, this function will be processed as follows:
|
|
||||||
// 1. Replace {WD} variable with the actual directory path
|
|
||||||
// 2. Replace ${GOPATH} with enviorment variable GOPATH
|
|
||||||
// 3. Replace "/" with "\\" (Windows)
|
|
||||||
func (c *conf) GetWorkspace() string {
|
|
||||||
w := strings.Replace(c.Workspace, "{WD}", c.WD, 1)
|
|
||||||
w = strings.Replace(w, "${GOPATH}", os.Getenv("GOPATH"), 1)
|
|
||||||
|
|
||||||
return filepath.FromSlash(w)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetGoFmt gets the path of Go format tool, returns "gofmt" if not found.
|
// GetGoFmt gets the path of Go format tool, returns "gofmt" if not found.
|
||||||
func (c *conf) GetGoFmt(username string) string {
|
func (c *conf) GetGoFmt(username string) string {
|
||||||
for _, user := range c.Users {
|
for _, user := range c.Users {
|
||||||
|
@ -359,11 +345,11 @@ func UpdateCustomizedConf(username string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// initWorkspaceDirs initializes the directories of master workspace, users' workspaces.
|
// initWorkspaceDirs initializes the directories of users' workspaces.
|
||||||
//
|
//
|
||||||
// Creates directories if not found on path of workspace.
|
// Creates directories if not found on path of workspace.
|
||||||
func initWorkspaceDirs() {
|
func initWorkspaceDirs() {
|
||||||
paths := filepath.SplitList(Wide.GetWorkspace())
|
paths := []string{}
|
||||||
|
|
||||||
for _, user := range Wide.Users {
|
for _, user := range Wide.Users {
|
||||||
paths = append(paths, filepath.SplitList(user.GetWorkspace())...)
|
paths = append(paths, filepath.SplitList(user.GetWorkspace())...)
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
"MaxProcs": 4,
|
"MaxProcs": 4,
|
||||||
"RuntimeMode": "dev",
|
"RuntimeMode": "dev",
|
||||||
"WD": "${pwd}",
|
"WD": "${pwd}",
|
||||||
"Workspace": "${GOPATH}",
|
|
||||||
"Locale": "en_US",
|
"Locale": "en_US",
|
||||||
"Users": [
|
"Users": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -345,7 +345,14 @@ func listFiles(dirname string) []string {
|
||||||
|
|
||||||
// sort: directories in front of files
|
// sort: directories in front of files
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
fio, _ := os.Lstat(filepath.Join(dirname, name))
|
path := filepath.Join(dirname, name)
|
||||||
|
fio, err := os.Lstat(path)
|
||||||
|
|
||||||
|
if nil != err {
|
||||||
|
glog.Warningf("Can't read file info [%s]", path)
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if fio.IsDir() {
|
if fio.IsDir() {
|
||||||
// exclude the .git direcitory
|
// exclude the .git direcitory
|
||||||
|
|
|
@ -846,10 +846,9 @@ func StopHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
func setCmdEnv(cmd *exec.Cmd, username string) {
|
func setCmdEnv(cmd *exec.Cmd, username string) {
|
||||||
userWorkspace := conf.Wide.GetUserWorkspace(username)
|
userWorkspace := conf.Wide.GetUserWorkspace(username)
|
||||||
masterWorkspace := conf.Wide.GetWorkspace()
|
|
||||||
|
|
||||||
cmd.Env = append(cmd.Env,
|
cmd.Env = append(cmd.Env,
|
||||||
"GOPATH="+userWorkspace+conf.PathListSeparator+masterWorkspace,
|
"GOPATH="+userWorkspace,
|
||||||
"GOOS="+runtime.GOOS,
|
"GOOS="+runtime.GOOS,
|
||||||
"GOARCH="+runtime.GOARCH,
|
"GOARCH="+runtime.GOARCH,
|
||||||
"GOROOT="+runtime.GOROOT(),
|
"GOROOT="+runtime.GOROOT(),
|
||||||
|
|
Loading…
Reference in New Issue