From 760170e0078c1fd73710c0ab380199281a39397a Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 23 Oct 2014 13:54:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BE=93=E5=87=BA=E7=AA=97=E5=8F=A3=E7=9D=80?= =?UTF-8?q?=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- output/outputs.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/output/outputs.go b/output/outputs.go index 2fc7243..341f682 100644 --- a/output/outputs.go +++ b/output/outputs.go @@ -163,7 +163,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) { wsChannel := session.OutputWS[sid] channelRet["cmd"] = "run" - channelRet["output"] = string(buf[:count]) + channelRet["output"] = "
" + string(buf[:count]) + "
" err := wsChannel.Conn.WriteJSON(&channelRet) if nil != err { glog.Error(err) @@ -272,7 +272,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { if nil != session.OutputWS[sid] { // 在前端 output 中显示“开始构建” - channelRet["output"] = i18n.Get(r, "start-build").(string) + "\n" + channelRet["output"] = "" + i18n.Get(r, "start-build").(string) + "\n" channelRet["cmd"] = "start-build" wsChannel := session.OutputWS[sid] @@ -313,7 +313,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { if 0 == count { // 说明构建成功,没有错误信息输出 // 设置下一次执行命令(前端会根据这个发送请求) channelRet["nextCmd"] = args["nextCmd"] - channelRet["output"] = i18n.Get(r, "build-succ").(string) + "\n" + channelRet["output"] = "" + i18n.Get(r, "build-succ").(string) + "\n" go func() { // 运行 go install,生成的库用于 gocode lib-path cmd := exec.Command("go", "install") @@ -329,7 +329,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { } else { // 构建失败 // 解析错误信息,返回给编辑器 gutter lint errOut := string(buf[:count]) - channelRet["output"] = i18n.Get(r, "build-failed").(string) + "\n" + errOut + channelRet["output"] = "" + i18n.Get(r, "build-failed").(string) + "\n" + errOut lines := strings.Split(errOut, "\n") @@ -465,7 +465,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { if nil != session.OutputWS[sid] { // 在前端 output 中显示“开始 go install” - channelRet["output"] = i18n.Get(r, "start-install").(string) + "\n" + channelRet["output"] = "" + i18n.Get(r, "start-install").(string) + "\n" channelRet["cmd"] = "start-install" wsChannel := session.OutputWS[sid] @@ -500,7 +500,6 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { count, _ := reader.Read(buf) channelRet := map[string]interface{}{} - channelRet["cmd"] = "go install" if 0 != count { // 构建失败 @@ -547,9 +546,9 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { channelRet["lints"] = lints - channelRet["output"] = i18n.Get(r, "install-failed").(string) + "\n" + errOut + channelRet["output"] = "" + i18n.Get(r, "install-failed").(string) + "\n" + errOut } else { - channelRet["output"] = i18n.Get(r, "install-succ").(string) + "\n" + channelRet["output"] = "" + i18n.Get(r, "install-succ").(string) + "\n" } if nil != session.OutputWS[sid] { @@ -622,7 +621,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) { if nil != session.OutputWS[sid] { // 在前端 output 中显示“开始 go get - channelRet["output"] = i18n.Get(r, "start-get").(string) + "\n" + channelRet["output"] = "" + i18n.Get(r, "start-get").(string) + "\n" channelRet["cmd"] = "start-get" wsChannel := session.OutputWS[sid] @@ -664,7 +663,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) { if nil != err { glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done (with error)", sid, runningId) - channelRet["output"] = i18n.Get(r, "get-failed").(string) + "\n" + string(buf[:count]) + channelRet["output"] = "" + i18n.Get(r, "get-failed").(string) + "\n" + string(buf[:count]) if nil != session.OutputWS[sid] { wsChannel := session.OutputWS[sid] @@ -685,7 +684,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) { if 0 == count { glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done", sid, runningId) - channelRet["output"] = i18n.Get(r, "get-succ").(string) + "\n" + channelRet["output"] = "" + i18n.Get(r, "get-succ").(string) + "\n" if nil != session.OutputWS[sid] { wsChannel := session.OutputWS[sid]