Fix filepath things. This make wide possible to work "Build/Build&Run" on windows
This commit is contained in:
parent
f439a45ade
commit
45d4095401
|
@ -10,6 +10,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -74,7 +75,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
filePath := args["executable"].(string)
|
filePath := args["executable"].(string)
|
||||||
curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)]
|
curDir := filepath.Dir(filePath)
|
||||||
|
|
||||||
cmd := exec.Command(filePath)
|
cmd := exec.Command(filePath)
|
||||||
cmd.Dir = curDir
|
cmd.Dir = curDir
|
||||||
|
@ -198,7 +199,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
sid := args["sid"].(string)
|
sid := args["sid"].(string)
|
||||||
|
|
||||||
filePath := args["file"].(string)
|
filePath := args["file"].(string)
|
||||||
curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)]
|
curDir := filepath.Dir(filePath)
|
||||||
|
|
||||||
fout, err := os.Create(filePath)
|
fout, err := os.Create(filePath)
|
||||||
|
|
||||||
|
@ -234,7 +235,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
glog.V(5).Infof("go build -o %s", executable)
|
glog.V(5).Infof("go build -o %s", executable)
|
||||||
|
|
||||||
executable = curDir + conf.PathSeparator + executable
|
executable = filepath.Join(curDir, executable)
|
||||||
|
|
||||||
// 先把可执行文件删了
|
// 先把可执行文件删了
|
||||||
err = os.RemoveAll(executable)
|
err = os.RemoveAll(executable)
|
||||||
|
@ -407,7 +408,7 @@ func GoTestHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
sid := args["sid"].(string)
|
sid := args["sid"].(string)
|
||||||
|
|
||||||
filePath := args["file"].(string)
|
filePath := args["file"].(string)
|
||||||
curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)]
|
curDir := filepath.Dir(filePath)
|
||||||
|
|
||||||
cmd := exec.Command("go", "test", "-v")
|
cmd := exec.Command("go", "test", "-v")
|
||||||
cmd.Dir = curDir
|
cmd.Dir = curDir
|
||||||
|
@ -522,7 +523,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
sid := args["sid"].(string)
|
sid := args["sid"].(string)
|
||||||
|
|
||||||
filePath := args["file"].(string)
|
filePath := args["file"].(string)
|
||||||
curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)]
|
curDir := filepath.Dir(filePath)
|
||||||
|
|
||||||
cmd := exec.Command("go", "install")
|
cmd := exec.Command("go", "install")
|
||||||
cmd.Dir = curDir
|
cmd.Dir = curDir
|
||||||
|
@ -678,7 +679,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
sid := args["sid"].(string)
|
sid := args["sid"].(string)
|
||||||
|
|
||||||
filePath := args["file"].(string)
|
filePath := args["file"].(string)
|
||||||
curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)]
|
curDir := filepath.Dir(filePath)
|
||||||
|
|
||||||
cmd := exec.Command("go", "get")
|
cmd := exec.Command("go", "get")
|
||||||
cmd.Dir = curDir
|
cmd.Dir = curDir
|
||||||
|
@ -802,7 +803,7 @@ func setCmdEnv(cmd *exec.Cmd, username string) {
|
||||||
masterWorkspace := conf.Wide.GetWorkspace()
|
masterWorkspace := conf.Wide.GetWorkspace()
|
||||||
|
|
||||||
cmd.Env = append(cmd.Env,
|
cmd.Env = append(cmd.Env,
|
||||||
"GOPATH="+userWorkspace+conf.PathListSeparator+masterWorkspace,
|
"GOPATH="+filepath.Join(userWorkspace, masterWorkspace),
|
||||||
"GOOS="+runtime.GOOS,
|
"GOOS="+runtime.GOOS,
|
||||||
"GOARCH="+runtime.GOARCH,
|
"GOARCH="+runtime.GOARCH,
|
||||||
"GOROOT="+runtime.GOROOT(),
|
"GOROOT="+runtime.GOROOT(),
|
||||||
|
|
Loading…
Reference in New Issue